Commit d77275ff authored by webchick's avatar webchick

Issue #1391694 by tim.plunkett, aspilicious, fago, pounard, plach, Crell,...

Issue #1391694 by tim.plunkett, aspilicious, fago, pounard, plach, Crell, msonnabaum, tstoeckler: Use type-hinting for entity-parameters.
parent 3b5fd77f
<?php
/**
* @file
* Contains \Drupal\aggregator\Plugin\Core\Entity\FeedInterface.
*/
namespace Drupal\aggregator;
use Drupal\Core\Entity\ContentEntityInterface;
/**
* Provides an interface defining an aggregator feed entity.
*/
interface FeedInterface extends ContentEntityInterface {
}
<?php
/**
* @file
* Contains \Drupal\aggregator\Plugin\Core\Entity\ItemInterface.
*/
namespace Drupal\aggregator;
use Drupal\Core\Entity\ContentEntityInterface;
/**
* Provides an interface defining an aggregator item entity.
*/
interface ItemInterface extends ContentEntityInterface {
}
......@@ -7,10 +7,10 @@
namespace Drupal\aggregator\Plugin\Core\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityNG;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
use Drupal\aggregator\FeedInterface;
/**
* Defines the aggregator feed entity class.
......@@ -34,7 +34,7 @@
* }
* )
*/
class Feed extends EntityNG implements ContentEntityInterface {
class Feed extends EntityNG implements FeedInterface {
/**
* The feed ID.
......
......@@ -7,10 +7,10 @@
namespace Drupal\aggregator\Plugin\Core\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityNG;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
use Drupal\aggregator\ItemInterface;
/**
* Defines the aggregator item entity class.
......@@ -31,7 +31,7 @@
* }
* )
*/
class Item extends EntityNG implements ContentEntityInterface {
class Item extends EntityNG implements ItemInterface {
/**
* The feed item ID.
......
......@@ -23,7 +23,7 @@
* A renderable array of data, as returned from the build() implementation of
* the plugin that defined the block:
* - #title: The default localized title of the block.
* @param \Drupal\block\BlockInterface $block
* @param \Drupal\block\BlockPluginInterface $block
* The block instance.
*
* @see hook_block_view_ID_alter()
......@@ -51,7 +51,7 @@ function hook_block_view_alter(array &$build, \Drupal\block\Plugin\Core\Entity\B
* A renderable array of data, as returned from the build() implementation of
* the plugin that defined the block:
* - #title: The default localized title of the block.
* @param \Drupal\block\BlockInterface $block
* @param \Drupal\block\BlockPluginInterface $block
* The block instance.
*
* @todo Add a more specific example of a block ID, and illustrate how this is
......@@ -60,7 +60,7 @@ function hook_block_view_alter(array &$build, \Drupal\block\Plugin\Core\Entity\B
* @see hook_block_view_alter()
* @see hook_block_view_NAME_alter()
*/
function hook_block_view_ID_alter(array &$build, \Drupal\block\BlockInterface $block) {
function hook_block_view_ID_alter(array &$build, \Drupal\block\BlockPluginInterface $block) {
// This code will only run for a specific block. For example, if ID
// in the function definition above is set to "someid", the code
// will only run on the "someid" block.
......@@ -79,7 +79,7 @@ function hook_block_view_ID_alter(array &$build, \Drupal\block\BlockInterface $b
* A renderable array of data, as returned from the build() implementation of
* the plugin that defined the block:
* - #title: The default localized title of the block.
* @param \Drupal\block\BlockInterface $block
* @param \Drupal\block\BlockPluginInterface $block
* The block instance.
*
* @todo NAME is ambiguous, and so is the example here. Use a more specific
......@@ -89,7 +89,7 @@ function hook_block_view_ID_alter(array &$build, \Drupal\block\BlockInterface $b
* @see hook_block_view_alter()
* @see hook_block_view_ID_alter()
*/
function hook_block_view_NAME_alter(array &$build, \Drupal\block\BlockInterface $block) {
function hook_block_view_NAME_alter(array &$build, \Drupal\block\BlockPluginInterface $block) {
// This code will only run for a specific block instance. For example, if NAME
// in the function definition above is set to "someid", the code will only run
// on the "someid" block.
......
<?php
/**
* @file
* Contains \Drupal\custom_block\Plugin\Core\Entity\CustomBlockInterface.
*/
namespace Drupal\custom_block;
use Drupal\Core\Entity\ContentEntityInterface;
/**
* Provides an interface defining a custom block entity.
*/
interface CustomBlockInterface extends ContentEntityInterface {
/**
* Sets the theme value.
*
* When creating a new custom block from the block library, the user is
* redirected to the configure form for that block in the given theme. The
* theme is stored against the block when the custom block add form is shown.
*
* @param string $theme
* The theme name.
*/
public function setTheme($theme);
/**
* Gets the theme value.
*
* When creating a new custom block from the block library, the user is
* redirected to the configure form for that block in the given theme. The
* theme is stored against the block when the custom block add form is shown.
*
* @return string
* The theme name.
*/
public function getTheme();
}
<?php
/**
* @file
* Contains \Drupal\custom_block\Plugin\Core\Entity\CustomBlockTypeInterface.
*/
namespace Drupal\custom_block;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Provides an interface defining a custom block type entity.
*/
interface CustomBlockTypeInterface extends ConfigEntityInterface {
}
......@@ -7,10 +7,10 @@
namespace Drupal\custom_block\Plugin\Core\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityNG;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
use Drupal\custom_block\CustomBlockInterface;
/**
* Defines the custom block entity class.
......@@ -46,7 +46,7 @@
* }
* )
*/
class CustomBlock extends EntityNG implements ContentEntityInterface {
class CustomBlock extends EntityNG implements CustomBlockInterface {
/**
* The block ID.
......@@ -151,28 +151,14 @@ public function getRevisionId() {
}
/**
* Sets the theme value.
*
* When creating a new custom block from the block library, the user is
* redirected to the configure form for that block in the given theme. The
* theme is stored against the block when the custom block add form is shown.
*
* @param string $theme
* The theme name.
* {@inheritdoc}
*/
public function setTheme($theme) {
$this->theme = $theme;
}
/**
* Gets the theme value.
*
* When creating a new custom block from the block library, the user is
* redirected to the configure form for that block in the given theme. The
* theme is stored against the block when the custom block add form is shown.
*
* @return string
* The theme name.
* {@inheritdoc}
*/
public function getTheme() {
return $this->theme;
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
use Drupal\custom_block\CustomBlockTypeInterface;
/**
* Defines the custom block type entity.
......@@ -33,7 +34,7 @@
* }
* )
*/
class CustomBlockType extends ConfigEntityBase {
class CustomBlockType extends ConfigEntityBase implements CustomBlockTypeInterface {
/**
* The custom block type ID.
......
......@@ -18,7 +18,7 @@
* block settings, and handling for general user-defined block visibility
* settings.
*/
abstract class BlockBase extends PluginBase implements BlockInterface {
abstract class BlockBase extends PluginBase implements BlockPluginInterface {
/**
* The entity using this plugin.
......@@ -118,7 +118,7 @@ public function blockAccess() {
}
/**
* Implements \Drupal\block\BlockInterface::access().
* Implements \Drupal\block\BlockPluginInterface::access().
*
* Adds the user-configured per-role, per-path, and per-language visibility
* settings to all blocks, and invokes hook_block_access().
......@@ -212,7 +212,7 @@ public function access() {
}
/**
* Implements \Drupal\block\BlockInterface::form().
* Implements \Drupal\block\BlockPluginInterface::form().
*
* Creates a generic configuration form for all block types. Individual
* block plugins can add elements to this form by overriding
......@@ -419,7 +419,7 @@ public function blockForm($form, &$form_state) {
}
/**
* Implements \Drupal\block\BlockInterface::validate().
* Implements \Drupal\block\BlockPluginInterface::validate().
*
* Most block plugins should not override this method. To add validation
* for a specific block type, override BlockBase::blockValdiate().
......@@ -459,7 +459,7 @@ public function validate($form, &$form_state) {
public function blockValidate($form, &$form_state) {}
/**
* Implements \Drupal\block\BlockInterface::submit().
* Implements \Drupal\block\BlockPluginInterface::submit().
*
* Most block plugins should not override this method. To add submission
* handling for a specific block type, override BlockBase::blockSubmit().
......
......@@ -2,104 +2,24 @@
/**
* @file
* Contains \Drupal\block\BlockInterface.
* Contains \Drupal\block\Plugin\Core\Entity\BlockInterface.
*/
namespace Drupal\block;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Defines the required interface for all block plugins.
*
* @todo Add detailed documentation here explaining the block system's
* architecture and the relationships between the various objects, including
* brif references to the important components that are not coupled to the
* interface.
*
* @see \Drupal\block\BlockBase
* Provides an interface defining a block entity.
*/
interface BlockInterface {
/**
* Returns the default settings for this block plugin.
*
* @return array
* An associative array of block settings for this block, keyed by the
* setting name.
*
* @todo Consider merging this with the general plugin configuration member
* variable and its getter/setter in http://drupal.org/node/1764380.
*/
public function settings();
/**
* Indicates whether the block should be shown.
*
* This method allows base implementations to add general access restrictions
* that should apply to all extending block plugins.
*
* @return bool
* TRUE if the block should be shown, or FALSE otherwise.
*
* @see \Drupal\block\BlockAccessController
*/
public function access();
/**
* Constructs the block configuration form.
*
* This method allows base implementations to add a generic configuration
* form for extending block plugins.
*
* @param array $form
* The form definition array for the block configuration form.
* @param array $form_state
* An array containing the current state of the configuration form.
*
* @return array $form
* The renderable form array representing the entire configuration form.
*
* @see \Drupal\block\BlockFormController::form()
* @see \Drupal\block\BlockInterace::validate()
* @see \Drupal\block\BlockInterace::submit()
*/
public function form($form, &$form_state);
interface BlockInterface extends ConfigEntityInterface {
/**
* Handles form validation for the block configuration form.
*
* @param array $form
* The form definition array for the block configuration form.
* @param array $form_state
* An array containing the current state of the configuration form.
*
* @see \Drupal\block\BlockFormController::validate()
* @see \Drupal\block\BlockInterace::form()
* @see \Drupal\block\BlockInterace::submit()
*/
public function validate($form, &$form_state);
/**
* Handles form submissions for the block configuration form.
*
* @param array $form
* The form definition array for the block configuration form.
* @param array $form_state
* An array containing the current state of the configuration form.
*
* @see \Drupal\block\BlockFormController::submit()
* @see \Drupal\block\BlockInterace::form()
* @see \Drupal\block\BlockInterace::validate()
*/
public function submit($form, &$form_state);
/**
* Builds and returns the renderable array for this block plugin.
*
* @return array
* A renderable array representing the content of the block.
* Returns the plugin instance.
*
* @see \Drupal\block\BlockRenderController
* @return \Drupal\block\BlockPluginInterface
* The plugin instance for this block.
*/
public function build();
public function getPlugin();
}
<?php
/**
* @file
* Contains \Drupal\block\BlockPluginInterface.
*/
namespace Drupal\block;
/**
* Defines the required interface for all block plugins.
*
* @todo Add detailed documentation here explaining the block system's
* architecture and the relationships between the various objects, including
* brif references to the important components that are not coupled to the
* interface.
*
* @see \Drupal\block\BlockBase
*/
interface BlockPluginInterface {
/**
* Returns the default settings for this block plugin.
*
* @return array
* An associative array of block settings for this block, keyed by the
* setting name.
*
* @todo Consider merging this with the general plugin configuration member
* variable and its getter/setter in http://drupal.org/node/1764380.
*/
public function settings();
/**
* Indicates whether the block should be shown.
*
* This method allows base implementations to add general access restrictions
* that should apply to all extending block plugins.
*
* @return bool
* TRUE if the block should be shown, or FALSE otherwise.
*
* @see \Drupal\block\BlockAccessController
*/
public function access();
/**
* Constructs the block configuration form.
*
* This method allows base implementations to add a generic configuration
* form for extending block plugins.
*
* @param array $form
* The form definition array for the block configuration form.
* @param array $form_state
* An array containing the current state of the configuration form.
*
* @return array $form
* The renderable form array representing the entire configuration form.
*
* @see \Drupal\block\BlockFormController::form()
* @see \Drupal\block\BlockInterace::validate()
* @see \Drupal\block\BlockInterace::submit()
*/
public function form($form, &$form_state);
/**
* Handles form validation for the block configuration form.
*
* @param array $form
* The form definition array for the block configuration form.
* @param array $form_state
* An array containing the current state of the configuration form.
*
* @see \Drupal\block\BlockFormController::validate()
* @see \Drupal\block\BlockInterace::form()
* @see \Drupal\block\BlockInterace::submit()
*/
public function validate($form, &$form_state);
/**
* Handles form submissions for the block configuration form.
*
* @param array $form
* The form definition array for the block configuration form.
* @param array $form_state
* An array containing the current state of the configuration form.
*
* @see \Drupal\block\BlockFormController::submit()
* @see \Drupal\block\BlockInterace::form()
* @see \Drupal\block\BlockInterace::validate()
*/
public function submit($form, &$form_state);
/**
* Builds and returns the renderable array for this block plugin.
*
* @return array
* A renderable array representing the content of the block.
*
* @see \Drupal\block\BlockRenderController
*/
public function build();
}
......@@ -11,6 +11,7 @@
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\block\BlockInterface;
/**
* Defines a Block configuration entity class.
......@@ -38,7 +39,7 @@
* }
* )
*/
class Block extends ConfigEntityBase {
class Block extends ConfigEntityBase implements BlockInterface {
/**
* The ID of the block.
......@@ -82,7 +83,7 @@ class Block extends ConfigEntityBase {
/**
* The plugin instance.
*
* @var \Drupal\block\BlockInterface
* @var \Drupal\block\BlockPluginInterface
*/
protected $instance;
......@@ -122,10 +123,7 @@ class Block extends ConfigEntityBase {
protected $plugin;
/**
* Returns the plugin instance.
*
* @return \Drupal\block\BlockInterface
* The plugin instance for this block.
* {@inheritdoc}
*/
public function getPlugin() {
if (!$this->instance) {
......
......@@ -20,7 +20,7 @@
*
* @todo Add documentation to this class.
*
* @see \Drupal\block\BlockInterface
* @see \Drupal\block\BlockPluginInterface
*/
class BlockManager extends PluginManagerBase {
......
<?php
/**
* @file
* Contains \Drupal\breakpoint\Plugin\Core\Entity\BreakpointGroupInterface.
*/
namespace Drupal\breakpoint;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Provides an interface defining a breakpoint group entity.
*/
interface BreakpointGroupInterface extends ConfigEntityInterface {
/**
* Checks if the breakpoint group is valid.
*
* @throws \Drupal\breakpoint\InvalidBreakpointSourceTypeException
* @throws \Drupal\breakpoint\InvalidBreakpointSourceException
*
* @return bool
* Returns TRUE if the breakpoint group is valid.
*/
public function isValid();
/**
* Adds a breakpoint using a name and a media query.
*
* @param string $name
* The name of the breakpoint.
* @param string $media_query
* Media query.
*/
public function addBreakpointFromMediaQuery($name, $media_query);
/**
* Adds one or more breakpoints to this group.
*
* The breakpoint name is either the machine_name or the ID of a breakpoint.
*
* @param array $breakpoints
* Array containing breakpoints keyed by their ID.
*/
public function addBreakpoints($breakpoints);
}
<?php
/**
* @file
* Contains \Drupal\breakpoint\Plugin\Core\Entity\BreakpointInterface.
*/
namespace Drupal\breakpoint;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Provides an interface defining a breakpoint entity.
*/
interface BreakpointInterface extends ConfigEntityInterface {
/**
* Checks if the breakpoint is valid.
*
* @throws \Drupal\breakpoint\InvalidBreakpointSourceTypeException
* @throws \Drupal\breakpoint\InvalidBreakpointSourceException
* @throws \Drupal\breakpoint\InvalidBreakpointNameException
* @throws \Drupal\breakpoint\InvalidBreakpointMediaQueryException
*
* @see isValidMediaQuery()
*/
public function isValid();
/**
* Checks if a mediaQuery is valid.
*
* @throws \Drupal\breakpoint\InvalidBreakpointMediaQueryException
*
* @return bool
* Returns TRUE if the media query is valid.
*
* @see http://www.w3.org/TR/css3-mediaqueries/
* @see http://www.w3.org/Style/CSS/Test/MediaQueries/20120229/reports/implement-report.html
* @see https://github.com/adobe/webkit/blob/master/Source/WebCore/css/
*/
public static function isValidMediaQuery($media_query);