Ejemplo n.º 1
0
 /**
  * Returns a field type from the given config identifier if it represents a field
  *
  * @param ConfigIdInterface $configId
  *
  * @return string|null A field type if $configId represents a field; otherwise, null
  */
 public function getFieldType(ConfigIdInterface $configId)
 {
     if ($configId instanceof FieldConfigId) {
         return $configId->getFieldType();
     }
     return null;
 }
 /**
  * Creates an instance if Config class which stores configuration data for an object
  * which is represented by the given id.
  * The returned object is initialized with data specified $values argument.
  *
  * @param  ConfigIdInterface $configId
  * @param  array             $values An associative array contains configuration properties
  *                                   key = property name
  *                                   value = property value
  * @return Config
  */
 public function createConfig(ConfigIdInterface $configId, array $values)
 {
     $config = new Config($configId);
     if ($configId instanceof FieldConfigId) {
         $type = PropertyConfigContainer::TYPE_FIELD;
         $defaultValues = $this->getPropertyConfig()->getDefaultValues($type, $configId->getFieldType());
     } else {
         $type = PropertyConfigContainer::TYPE_ENTITY;
         $defaultValues = $this->getPropertyConfig()->getDefaultValues($type);
     }
     $values = array_merge($defaultValues, $values);
     foreach ($values as $key => $value) {
         $config->set($key, $value);
     }
     $this->merge($config);
     return $config;
 }