"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/lib/Drupal/Core/Config/Schema/Element.php" (26 Nov 2020, 1771 Bytes) of package /linux/www/drupal-8.9.10.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 "Element.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\Core\Config\Schema;
    4 
    5 use Drupal\Core\Config\TypedConfigManagerInterface;
    6 use Drupal\Core\TypedData\TypedData;
    7 use Drupal\Core\TypedData\TypedDataManagerInterface;
    8 
    9 /**
   10  * Defines a generic configuration element.
   11  */
   12 abstract class Element extends TypedData {
   13 
   14   /**
   15    * The configuration value.
   16    *
   17    * @var mixed
   18    */
   19   protected $value;
   20 
   21   /**
   22    * Gets the typed configuration manager.
   23    *
   24    * Overrides \Drupal\Core\TypedData\TypedDataTrait::getTypedDataManager() to
   25    * ensure the typed configuration manager is returned.
   26    *
   27    * @return \Drupal\Core\Config\TypedConfigManagerInterface
   28    *   The typed configuration manager.
   29    */
   30   public function getTypedDataManager() {
   31     if (empty($this->typedDataManager)) {
   32       $this->setTypedDataManager(\Drupal::service('config.typed'));
   33     }
   34 
   35     return $this->typedDataManager;
   36   }
   37 
   38   /**
   39    * Sets the typed config manager.
   40    *
   41    * Overrides \Drupal\Core\TypedData\TypedDataTrait::setTypedDataManager() to
   42    * ensure that only typed configuration manager can be used.
   43    *
   44    * @param \Drupal\Core\TypedData\TypedDataManagerInterface $typed_data_manager
   45    *   The typed config manager. This must be an instance of
   46    *   \Drupal\Core\Config\TypedConfigManagerInterface. If it is not, then this
   47    *   method will error when assertions are enabled. We can not narrow the
   48    *   typehint as this will cause PHP errors.
   49    *
   50    * @return $this
   51    */
   52   public function setTypedDataManager(TypedDataManagerInterface $typed_data_manager) {
   53     assert($typed_data_manager instanceof TypedConfigManagerInterface, '$typed_data_manager should be an instance of \Drupal\Core\Config\TypedConfigManagerInterface.');
   54     $this->typedDataManager = $typed_data_manager;
   55     return $this;
   56   }
   57 
   58 }