コード例 #1
0
ファイル: ResourceHelper.php プロジェクト: pscheit/psc-cms
 /**
  *
  * in einem PHPUnit - TestCase darf man dann das hier machen:
  * 
  * $baseDir = $resourceHelper->getBaseDirectory($this);
  *
  * Was dann in diesem Dir liegt bleibt dem Test überlassen
  */
 public function getTestDirectory(\PHPUnit_Framework_TestCase $test)
 {
     if ($this->usePersonalDirs) {
         $testName = Code::getClassName(get_class($test));
         return $this->getFixturesDirectory()->sub($testName . '/');
     } else {
         return $this->project->dir('test-files');
     }
 }
コード例 #2
0
ファイル: ComponentsForm.php プロジェクト: pscheit/psc-cms
 /**
 * 
 * $content .= f::inputSet(
    f::input(
      $form->createTypeSelect('\SerienLoader\Status',$episode->getStatus())
    )
 */
 public function createTypeSelect($typeClass, $selected, $label = NULL, $field = NULL)
 {
     $type = $typeClass::instance();
     $values = $type->getValues();
     $options = array_combine($values, array_map('ucfirst', $values));
     if (!isset($field)) {
         $field = lcfirst(Code::getClassName($typeClass));
         // sowas wie \tiptoi\SpeakerType => speakerType
     }
     if (!isset($label)) {
         $label = ucfirst($field);
     }
     return f::select($label, lcfirst($field), $options, $selected);
 }
コード例 #3
0
ファイル: GFunction.php プロジェクト: pscheit/psc-cms
 /**
  * @param string $name FQN Name der Function/Methode
  * @param GParameter[] $parameters
  * @param string|array $body ist body ein array wird jeder Eintrag als string und als Zeile des Bodys ausgewertet
  */
 public function __construct($name = NULL, array $parameters = array(), $body = NULL)
 {
     parent::__construct();
     if ($name != NULL) {
         $this->namespace = Code::getNamespace($name);
         $this->name = Code::getClassName($name);
     }
     foreach ($parameters as $parameter) {
         $this->addParameter($parameter);
     }
     if (is_array($body)) {
         $this->setBodyCode($body);
     } elseif ($body != NULL) {
         $this->setBody($body);
     }
 }
コード例 #4
0
ファイル: ClassReader.php プロジェクト: pscheit/psc-cms
 public function readUseStatements()
 {
     // wir nehmen uns den Doctrine PHP Parser zur Hilfe (package: common)
     $dcUseStatements = $this->phpParser->parseClass($this->getReflectionClass());
     // ach manno, das sind alles lowercase names als Alias und man weiß nicht ob sie explizit sind oder nicht
     // das doch doof weil alle im phpParser von Doctrine private und final ist, geht da nix
     $useStatements = array();
     foreach ($dcUseStatements as $lowerAlias => $class) {
         if (mb_strtolower($cn = Code::getClassName($class)) !== $lowerAlias) {
             // ein expiziter Alias
             $useStatements[$lowerAlias] = new GClass($class);
         } else {
             $useStatements[$cn] = new GClass($class);
             // $cn nicht strtolower!
         }
     }
     return $useStatements;
 }
コード例 #5
0
ファイル: AbstractTask.php プロジェクト: pscheit/psc-cms
 public function __construct($taskName)
 {
     $this->taskName = $taskName ?: Code::getClassName(get_class($this));
 }
コード例 #6
0
ファイル: Base.php プロジェクト: pscheit/psc-cms
 /**
  * Gibt den Namen der Componente zurück
  *
  * also TextField oder EmailPicker oder ComboBox oder ComboDropBox usw
  */
 public function getComponentName()
 {
     return Code::getClassName(Code::getClass($this));
 }
コード例 #7
0
ファイル: EntityService.php プロジェクト: pscheit/psc-cms
 public function getEntityController($part)
 {
     $entityClass = $this->doctrine->getEntityName($part);
     $entityName = Code::getClassName($entityClass);
     return $this->controllerFactory->getController($entityName);
 }
コード例 #8
0
ファイル: LoggerObject.php プロジェクト: pscheit/psc-cms
 public function setLogger(\Psc\System\Logger $logger, $prefix = NULL)
 {
     $this->logger = $logger;
     $this->logger->setPrefix($prefix ?: '[' . Code::getClassName($this) . ']');
     return $this;
 }
コード例 #9
0
ファイル: GClass.php プロジェクト: pscheit/psc-cms
 /**
  * Setzt den Namen der Klasse
  *
  * Namespace wird immer mitgesetzt! D. h. übergibt man hier nur den ShortName wird der Namespace auf NULL gesetzt
  * Wenn man nur den Namen der Klasse und nicht den Namespace wechseln will, muss man setClassName() nehmen
  * @param string FQN;
  */
 public function setName($name)
 {
     if (mb_strpos($name, '\\') !== FALSE) {
         $this->setNamespace(Code::getNamespace($name));
         $this->name = Code::getClassName($name);
     } else {
         $this->name = $name;
         $this->namespace = NULL;
     }
     return $this;
 }
コード例 #10
0
ファイル: Processor.php プロジェクト: pscheit/psc-cms
 /**
  * Synchronisiert eine Collection eines Entities mit Entities in der Datenbank (deprecated)
  *
  * Diese Art der Synchroniserung ist deprecated, weil es mittlerweile ausgelagerte Funktionen dafür gibt
  * (siehe Psc\Doctrine\*Synchro*)
  * 
  * also es werden für die bestehenden Objekte in $entity->$collectionProperty die objekte gelöscht
  * die nicht in newCollection drin sind und die, die in $newCollection drin sind aber nicht in
  * $entity->$collectionProperty gelöscht
  * 
  * - Achtung(!): dies führt persist() auf den Entitys der Collection (also quasi andere Seite der Association) aus, wenn $this->entity nicht die Owning-Side der CollectionAssociation ist
  * - Dies führt persist für items in newCollection, die neu sind
  * 
  * Die Basis für eine erfolgreiche Synchronization ist eine $newCollection die wirklich die gleichen Objekte enthält, für die Updates gemacht werden sollen. Also vorsicht mit serialisierten Einträgen und clones
  * 
  * @param string $associationName der Name des Properties der Collection in $entity
  */
 public function synchronizeCollection($associationName, $newCollection)
 {
     if (!is_string($associationName)) {
         throw new \Psc\Exception('string erwartet: ' . Code::varInfo($associationName));
     }
     /*
         $mapping     = $coll->getMapping();
         $targetClass = $this->_em->getClassMetadata($mapping['targetEntity']);
         $sourceClass = $this->_em->getClassMetadata($mapping['sourceEntity']);
         $id          = $this->_em->getUnitOfWork()->getEntityIdentifier($coll->getOwner());
     */
     if ($this->entity instanceof \Psc\Doctrine\Object) {
         $entityClass = $this->entity->getDoctrineMetadata();
         // Sound
     } elseif ($this->entity instanceof \Psc\Doctrine\Entity) {
         $entityClass = $this->em->getClassMetadata($this->entity->getEntityName());
     } else {
         throw new \InvalidArgumentException('$this->entity ist von der Klasse: ' . Code::getClass($this->entity) . ' und diese ist unbekannt');
     }
     $entityAssoc = $entityClass->getAssociationMapping($associationName);
     // speakers
     $owning = $entityAssoc['isOwningSide'];
     // true
     $targetClass = $this->em->getClassMetadata($entityAssoc['targetEntity']);
     // Metadata:Speaker
     if ($owning) {
         $entityProperty = $entityAssoc['inversedBy'];
         $collectionProperty = $entityAssoc['fieldName'];
     } else {
         $entityProperty = $entityAssoc['mappedBy'];
         $collectionProperty = $entityAssoc['fieldName'];
     }
     // entityProperty = sounds
     // collectionProperty = speakers
     $getter = Code::castGetter($collectionProperty);
     //getSpeakers
     $collection = $getter($this->entity);
     // $this->entity->getSpeakers()
     $collection = Code::castCollection($collection);
     $newCollection = Code::castCollection($newCollection);
     $this->log(sprintf("synchronizeCollection '%s'", $associationName));
     $this->log('in DBCollection:');
     $this->log(DoctrineHelper::debugCollection($collection));
     $this->log(NULL);
     $this->log('in FormCollection:');
     $this->log(DoctrineHelper::debugCollection($newCollection));
     $this->log(NULL);
     $this->log('Processing:');
     /*
       Wir synchronisieren hier auf der Owning Side oder Reverse Side
       jenachdem müssen wir auf der owning oder reverse side die add + remove funktionen aufrufen
     */
     if ($owning) {
         $remove = 'remove' . ucfirst(Inflector::singular($collectionProperty));
         // removeSpeaker
         $add = 'add' . ucfirst(Inflector::singular($collectionProperty));
         // addSpeaker
     } else {
         $remove = 'remove' . ucfirst(Inflector::singular($entityProperty));
         // removeSound
         $add = 'add' . ucfirst(Inflector::singular($entityProperty));
         // addSound
     }
     $logThis = Code::getClassName($entityClass->getName());
     // @TODO hier mit reflection prüfen
     //if (!->hasMethod($remove)) {
     //  throw new \Psc\Exception('Es gibt keine '.$remove.' Methode im Entity: '.$owningEntity);
     //}
     //if (!$this->entity->hasMethod($add)) {
     //  throw new \Psc\Exception('Es gibt keine '.$add.' Methode im Entity: '.$owningEntity);
     //}
     //
     foreach ($collection->deleteDiff($newCollection, ArrayCollection::COMPARE_OBJECTS) as $entity) {
         if ($owning) {
             $this->entity->{$remove}($entity);
             // $sound->removeSpeaker($speaker)
         } else {
             $this->em->persist($entity);
             // $speaker persist
             $entity->{$remove}($this->entity);
             // $speaker->removeSound($sound)
         }
     }
     foreach ($collection->insertDiff($newCollection, ArrayCollection::COMPARE_OBJECTS) as $entity) {
         if ($owning) {
             $this->entity->{$add}($entity);
             $this->em->persist($entity);
         } else {
             $entity->{$add}($this->entity);
             $this->em->persist($entity);
         }
     }
 }
コード例 #11
0
ファイル: Manager.php プロジェクト: pscheit/psc-cms-image
 public function registerCacheAdapter(CacheAdapter $adapter, $name = NULL)
 {
     if (!isset($name)) {
         $name = Code::getClassName(Code::getClass($adapter));
     }
     $this->registeredCacheAdapters[$name] = $adapter;
     return $this;
 }
コード例 #12
0
ファイル: EntryEntity.php プロジェクト: pscheit/psc-cms
 /**
  * @return string the name of the JS Class without Psc.UI.LayoutManagerComponent.
  */
 public function getType()
 {
     return Code::getClassName($this->getEntityName());
 }
コード例 #13
0
ファイル: Deployer.php プロジェクト: pscheit/psc-cms
 public function deploy()
 {
     $this->init();
     $this->logf('Starting Deployment [%s%s] to %s', $this->project->getName(), $this->variant ? '.' . $this->variant : NULL, $this->target);
     foreach ($this->tasks as $task) {
         try {
             $label = $task instanceof LabelTask ? $task->getLabel() : Code::getClassName(Code::getClass($task));
             $this->logf('** Task: %s', $label);
             $task->run();
         } catch (\Webforge\Common\Exception\MessageException $e) {
             $e->prependMessage('ERROR in task ' . $label . '. ');
             throw $e;
         }
     }
     $this->logf('finished Deployment [%s%s]', $this->project->getName(), $this->variant ? '.' . $this->variant : NULL);
 }