Esempio n. 1
0
 /**
  * Checks whether a field is configurable.
  *
  * @param string $className
  * @param string $fieldName
  *
  * @return bool
  */
 protected function isConfigurableField($className, $fieldName)
 {
     $isConfigurable = $this->cache->getConfigurable($className, $fieldName);
     if (null === $isConfigurable) {
         $isConfigurable = null !== $this->modelManager->findFieldModel($className, $fieldName);
         $this->cache->saveConfigurable($isConfigurable, $className, $fieldName);
     }
     return $isConfigurable;
 }
 public function testChangeFieldName()
 {
     $entityModel = $this->createEntityModel(self::TEST_ENTITY);
     $fieldModel = $this->createFieldModel($entityModel, self::TEST_FIELD);
     $this->createRepositoryMock([$entityModel], [UnitOfWork::STATE_MANAGED, UnitOfWork::STATE_MANAGED, UnitOfWork::STATE_MANAGED]);
     $this->em->expects($this->once())->method('persist')->with($this->equalTo($fieldModel));
     $this->em->expects($this->never())->method('flush');
     $result = $this->configModelManager->changeFieldName(self::TEST_ENTITY, self::TEST_FIELD, 'newField');
     $this->assertTrue($result);
     $this->assertEquals('newField', $this->configModelManager->getFieldModel(self::TEST_ENTITY, 'newField')->getFieldName());
     $this->assertNull($this->configModelManager->findFieldModel(self::TEST_ENTITY, self::TEST_FIELD));
 }
Esempio n. 3
0
 /**
  * @param string $className
  * @param string $fieldName
  * @param string $fieldType
  * @param string $mode
  * @return FieldConfigModel
  */
 public function createConfigFieldModel($className, $fieldName, $fieldType, $mode = ConfigModelManager::MODE_DEFAULT)
 {
     $fieldModel = $this->modelManager->findFieldModel($className, $fieldName);
     if (null === $fieldModel) {
         $fieldModel = $this->modelManager->createFieldModel($className, $fieldName, $fieldType, $mode);
         $metadata = $this->getFieldMetadata($className, $fieldName);
         foreach ($this->getProviders() as $provider) {
             $configId = new FieldConfigId($provider->getScope(), $className, $fieldName, $fieldType);
             $config = $this->createConfig($configId, $this->getFieldDefaultValues($provider, $className, $fieldName, $fieldType, $metadata));
             $configKey = $this->buildConfigKey($config->getId());
             // local cache
             $this->localCache[$configKey] = $config;
             // for calculate change set
             $this->originalConfigs[$configKey] = clone $config;
         }
         $this->eventDispatcher->dispatch(Events::NEW_FIELD_CONFIG, new FieldConfigEvent($className, $fieldName, $this));
     }
     return $fieldModel;
 }