コード例 #1
0
 /**
  * @param LoggerInterface $logger
  * @param bool            $dryRun
  */
 protected function runActivityLists(LoggerInterface $logger, $dryRun = false)
 {
     // @todo: this workaround should be removed in BAP-9156
     $this->configManager->clear();
     $targetEntities = $this->provider->getTargetEntityClasses(false);
     $toSchema = clone $this->schema;
     $hasSchemaChanges = false;
     foreach ($targetEntities as $targetEntity) {
         $associationName = ExtendHelper::buildAssociationName($targetEntity, ActivityListEntityConfigDumperExtension::ASSOCIATION_KIND);
         $relationTableName = $this->nameGenerator->generateManyToManyJoinTableName(ActivityListEntityConfigDumperExtension::ENTITY_CLASS, $associationName, $targetEntity);
         if (!$toSchema->hasTable($relationTableName)) {
             $hasSchemaChanges = true;
             $this->activityListExtension->addActivityListAssociation($toSchema, $this->metadataHelper->getTableNameByEntityClass($targetEntity));
         }
     }
     if ($hasSchemaChanges) {
         $comparator = new Comparator();
         $platform = $this->connection->getDatabasePlatform();
         $schemaDiff = $comparator->compare($this->schema, $toSchema);
         $queries = $schemaDiff->toSql($platform);
         foreach ($queries as $query) {
             $this->logQuery($logger, $query);
             if (!$dryRun) {
                 $this->connection->executeQuery($query);
             }
         }
     }
 }
コード例 #2
0
 public function testGetTargetEntityClasses()
 {
     $correctTarget = new EntityConfigId('entity', 'Acme\\DemoBundle\\Entity\\CorrectEntity');
     $notCorrectTarget = new EntityConfigId('entity', 'Acme\\DemoBundle\\Entity\\NotCorrectEntity');
     $this->configManager->expects($this->once())->method('getIds')->will($this->returnValue([$correctTarget, $notCorrectTarget]));
     $this->assertEquals(['Acme\\DemoBundle\\Entity\\CorrectEntity'], $this->provider->getTargetEntityClasses());
 }
コード例 #3
0
 /**
  * Checks if the entity can have activities
  *
  * @param object|null $entity
  * @return bool
  */
 public function isApplicable($entity = null)
 {
     if (null === $entity || !is_object($entity)) {
         return false;
     }
     $entityClass = $this->doctrineHelper->getEntityClass($entity);
     $id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
     $activityListRepo = $this->doctrine->getRepository('OroActivityListBundle:ActivityList');
     return in_array($entityClass, $this->activityListProvider->getTargetEntityClasses()) || (bool) $activityListRepo->getRecordsCountForTargetClassAndId($entityClass, $id);
 }
コード例 #4
0
 /**
  * Checks if the entity can have activities
  *
  * @param object|null $entity
  * @param int|null    $pageType
  * @return bool
  */
 public function isApplicable($entity = null, $pageType = null)
 {
     if ($pageType === null || !is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) {
         return false;
     }
     $pageType = (int) $pageType;
     $id = $this->doctrineHelper->getSingleEntityIdentifier($entity);
     $entityClass = $this->doctrineHelper->getEntityClass($entity);
     $activityListRepo = $this->doctrine->getRepository('OroActivityListBundle:ActivityList');
     return $this->isAllowedOnPage($entity, $pageType) && (in_array($entityClass, $this->activityListProvider->getTargetEntityClasses()) || (bool) $activityListRepo->getRecordsCountForTargetClassAndId($entityClass, $id));
 }
コード例 #5
0
 /**
  * Gets the list of configs for entities which can be the target of the association
  *
  * @return ConfigInterface[]
  */
 protected function getTargetEntityConfigs()
 {
     if (null === $this->targetEntityConfigs) {
         $targetEntityClasses = $this->listProvider->getTargetEntityClasses(false);
         $this->targetEntityConfigs = [];
         $configs = $this->configManager->getProvider('extend')->getConfigs();
         foreach ($configs as $config) {
             if ($config->is('upgradeable') && in_array($config->getId()->getClassName(), $targetEntityClasses)) {
                 $this->targetEntityConfigs[] = $config;
             }
         }
     }
     return $this->targetEntityConfigs;
 }
コード例 #6
0
ファイル: PlaceholderFilter.php プロジェクト: woei66/platform
 /**
  * Checks if the entity can have activities
  *
  * @param object|null $entity
  * @param int|null    $pageType
  *
  * @return bool
  */
 public function isApplicable($entity = null, $pageType = null)
 {
     if (null === $pageType || !is_object($entity) || !$this->doctrineHelper->isManageableEntity($entity) || $this->doctrineHelper->isNewEntity($entity)) {
         return false;
     }
     $entityClass = $this->doctrineHelper->getEntityClass($entity);
     if (isset($this->applicableCache[$entityClass])) {
         return $this->applicableCache[$entityClass];
     }
     $result = false;
     if ($this->configManager->hasConfig($entityClass) && $this->isAllowedOnPage($entityClass, $pageType) && $this->hasApplicableActivityAssociations($entityClass)) {
         $result = in_array($entityClass, $this->activityListProvider->getTargetEntityClasses(), true) || !$this->isActivityListEmpty($entityClass, $this->doctrineHelper->getSingleEntityIdentifier($entity));
     }
     $this->applicableCache[$entityClass] = $result;
     return $result;
 }
コード例 #7
0
 public function getTargetEntityClassesOnEmptyTargetList()
 {
     $this->configManager->expects($this->once())->method('getIds')->will($this->returnValue([]));
     $this->assertEquals([], $this->provider->getTargetEntityClasses());
     /**
      * Each subsequent execution of getTargetEntityClasses should NOT collect targets again
      */
     $this->provider->getTargetEntityClasses();
 }