"Fossies" - the Fresh Open Source Software Archive

Member "drupal-8.9.10/core/lib/Drupal/Core/Entity/BundleEntityFormBase.php" (26 Nov 2020, 1000 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 "BundleEntityFormBase.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 namespace Drupal\Core\Entity;
    4 
    5 /**
    6  * Class BundleEntityFormBase is a base form for bundle config entities.
    7  */
    8 class BundleEntityFormBase extends EntityForm {
    9 
   10   /**
   11    * Protects the bundle entity's ID property's form element against changes.
   12    *
   13    * This method is assumed to be called on a completely built entity form,
   14    * including a form element for the bundle config entity's ID property.
   15    *
   16    * @param array $form
   17    *   The completely built entity bundle form array.
   18    *
   19    * @return array
   20    *   The updated entity bundle form array.
   21    */
   22   protected function protectBundleIdElement(array $form) {
   23     $entity = $this->getEntity();
   24     $id_key = $entity->getEntityType()->getKey('id');
   25     assert(isset($form[$id_key]));
   26     $element = &$form[$id_key];
   27 
   28     // Make sure the element is not accidentally re-enabled if it has already
   29     // been disabled.
   30     if (empty($element['#disabled'])) {
   31       $element['#disabled'] = !$entity->isNew();
   32     }
   33     return $form;
   34   }
   35 
   36 }