"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.9/core/modules/content_moderation/src/ContentModerationState.php" (18 Nov 2020, 2477 Bytes) of package /linux/www/drupal-8.9.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ContentModerationState.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\content_moderation;
    4 
    5 use Drupal\workflows\StateInterface;
    6 
    7 /**
    8  * A value object representing a workflow state for content moderation.
    9  */
   10 class ContentModerationState implements StateInterface {
   11 
   12   /**
   13    * The vanilla state object from the Workflow module.
   14    *
   15    * @var \Drupal\workflows\StateInterface
   16    */
   17   protected $state;
   18 
   19   /**
   20    * If entities should be published if in this state.
   21    *
   22    * @var bool
   23    */
   24   protected $published;
   25 
   26   /**
   27    * If entities should be the default revision if in this state.
   28    *
   29    * @var bool
   30    */
   31   protected $defaultRevision;
   32 
   33   /**
   34    * ContentModerationState constructor.
   35    *
   36    * Decorates state objects to add methods to determine if an entity should be
   37    * published or made the default revision.
   38    *
   39    * @param \Drupal\workflows\StateInterface $state
   40    *   The vanilla state object from the Workflow module.
   41    * @param bool $published
   42    *   (optional) TRUE if entities should be published if in this state, FALSE
   43    *   if not. Defaults to FALSE.
   44    * @param bool $default_revision
   45    *   (optional) TRUE if entities should be the default revision if in this
   46    *   state, FALSE if not. Defaults to FALSE.
   47    */
   48   public function __construct(StateInterface $state, $published = FALSE, $default_revision = FALSE) {
   49     $this->state = $state;
   50     $this->published = $published;
   51     $this->defaultRevision = $default_revision;
   52   }
   53 
   54   /**
   55    * Determines if entities should be published if in this state.
   56    *
   57    * @return bool
   58    */
   59   public function isPublishedState() {
   60     return $this->published;
   61   }
   62 
   63   /**
   64    * Determines if entities should be the default revision if in this state.
   65    *
   66    * @return bool
   67    */
   68   public function isDefaultRevisionState() {
   69     return $this->defaultRevision;
   70   }
   71 
   72   /**
   73    * {@inheritdoc}
   74    */
   75   public function id() {
   76     return $this->state->id();
   77   }
   78 
   79   /**
   80    * {@inheritdoc}
   81    */
   82   public function label() {
   83     return $this->state->label();
   84   }
   85 
   86   /**
   87    * {@inheritdoc}
   88    */
   89   public function weight() {
   90     return $this->state->weight();
   91   }
   92 
   93   /**
   94    * {@inheritdoc}
   95    */
   96   public function canTransitionTo($to_state_id) {
   97     return $this->state->canTransitionTo($to_state_id);
   98   }
   99 
  100   /**
  101    * {@inheritdoc}
  102    */
  103   public function getTransitionTo($to_state_id) {
  104     return $this->state->getTransitionTo($to_state_id);
  105   }
  106 
  107   /**
  108    * {@inheritdoc}
  109    */
  110   public function getTransitions() {
  111     return $this->state->getTransitions();
  112   }
  113 
  114 }