Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / entity_reference_revisions / src / TypedData / EntityRevisionDataDefinition.php
1 <?php
2
3 namespace Drupal\entity_reference_revisions\TypedData;
4
5 use Drupal\Core\Entity\TypedData\EntityDataDefinition;
6 use Drupal\Core\Entity\TypedData\EntityDataDefinitionInterface;
7
8 /**
9  * A typed data definition class for describing entities.
10  */
11 class EntityRevisionDataDefinition extends EntityDataDefinition implements EntityDataDefinitionInterface {
12
13   /**
14    * {@inheritdoc}
15    */
16   public static function createFromDataType($data_type) {
17     $parts = explode(':', $data_type);
18     if ($parts[0] != 'entity_revision') {
19       throw new \InvalidArgumentException('Data type must be in the form of "entity_revision:ENTITY_TYPE:BUNDLE."');
20     }
21     $definition = static::create();
22     // Set the passed entity type and bundle.
23     if (isset($parts[1])) {
24       $definition->setEntityTypeId($parts[1]);
25     }
26     if (isset($parts[2])) {
27       $definition->setBundles(array($parts[2]));
28     }
29     return $definition;
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public function getDataType() {
36     $type = 'entity_revision';
37     if ($entity_type = $this->getEntityTypeId()) {
38       $type .= ':' . $entity_type;
39       // Append the bundle only if we know it for sure and it is not the default
40       // bundle.
41       if (($bundles = $this->getBundles()) && count($bundles) == 1) {
42         $bundle = reset($bundles);
43         if ($bundle != $entity_type) {
44           $type .= ':' . $bundle;
45         }
46       }
47     }
48     return $type;
49   }
50 }