/** * * 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'); } }
/** * * $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); }
/** * @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); } }
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; }
public function __construct($taskName) { $this->taskName = $taskName ?: Code::getClassName(get_class($this)); }
/** * 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)); }
public function getEntityController($part) { $entityClass = $this->doctrine->getEntityName($part); $entityName = Code::getClassName($entityClass); return $this->controllerFactory->getController($entityName); }
public function setLogger(\Psc\System\Logger $logger, $prefix = NULL) { $this->logger = $logger; $this->logger->setPrefix($prefix ?: '[' . Code::getClassName($this) . ']'); return $this; }
/** * 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; }
/** * 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); } } }
public function registerCacheAdapter(CacheAdapter $adapter, $name = NULL) { if (!isset($name)) { $name = Code::getClassName(Code::getClass($adapter)); } $this->registeredCacheAdapters[$name] = $adapter; return $this; }
/** * @return string the name of the JS Class without Psc.UI.LayoutManagerComponent. */ public function getType() { return Code::getClassName($this->getEntityName()); }
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); }