コード例 #1
0
 /**
  * Überprüft die Daten anhand der Constraints und fügt die Daten zum Index hinzu
  *
  * Schmeisst eine Exception wenn die daten bereits im Index sind
  * diese Exception wird mit duplicateIdentifier gesetzt, wenn in $data der key 'identifier' für den vorigen Index-Eintrag gesetzt war
  */
 public function process(array $data)
 {
     foreach ($this->uniqueConstraints as $constraint) {
         $constraintValue = array();
         foreach ($constraint->getKeys() as $key) {
             // da wir diese reihenfolge nehmen, ist diese immer gleich
             $type = $constraint->getKeyType($key);
             if (!array_key_exists($key, $data)) {
                 throw new WrongDataException(sprintf("In Data ist der Schlüssel '%s' nicht vorhanden. Erwartet: '%s'", $key, $type->getName()));
             }
             $value = $data[$key];
             if (!$this->typeMatcher->isTypeof($value, $type)) {
                 $e = new TypeExpectedException(sprintf("Data %s für Key: '%s' sollte vom Type '%s' sein", \Psc\Code\Code::varInfo($value), $key, $type->getName()));
                 $e->expectedType = $type;
                 throw $e;
             }
             $constraintValue[$key] = $value;
         }
         // schlüssel darf es nicht geben, wert nicht gesetzt kann es nicht geben
         if (($indexEntry = $this->index->get($constraintValue, FALSE, DataInput::THROW_EXCEPTION)) === FALSE) {
             // ok: nicht im index => zum index hinzufügen
             $this->index->set($constraintValue, array_key_exists('identifier', $data) ? $data['identifier'] : TRUE);
         } else {
             throw UniqueConstraintException::factory($constraint->getName(), $this->getStringValue($constraintValue), $constraintValue, !is_bool($indexEntry) ? $indexEntry : NULL);
         }
     }
 }
コード例 #2
0
ファイル: EnumType.php プロジェクト: pscheit/psc-cms
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if (!in_array($value, $this->getValues())) {
         throw new \InvalidArgumentException("Invalid '" . $this->name . "' value " . \Psc\Code\Code::varInfo($value) . ' Erlaubt sind: ' . \Psc\Code\Code::varInfo($this->values));
     }
     return $value;
 }
コード例 #3
0
ファイル: ComponentMapper.php プロジェクト: pscheit/psc-cms
 public function createComponent($class)
 {
     $class = Code::expandNamespace($class, 'Psc\\UI\\Component');
     $component = new $class();
     $this->manager->dispatchEvent(self::EVENT_COMPONENT_CREATED, array('component' => $component, 'componentClass' => $class), $this);
     return $component;
 }
コード例 #4
0
ファイル: RequestMatcher.php プロジェクト: pscheit/psc-cms
 public function matchIValue($value)
 {
     if (($p = mb_strtolower($this->part())) === $value) {
         return $this->success($p);
     }
     $this->fail($p . ' matched ' . Code::varInfo($value) . ' nicht');
 }
コード例 #5
0
ファイル: PanelButtons.php プロジェクト: pscheit/psc-cms
 public function __construct(array $buttons, TranslationContainer $translationContainer, $flags = NULL)
 {
     $this->translationContainer = $translationContainer;
     $this->buttons = array();
     foreach ($buttons as $button) {
         if ($button === 'save') {
             $this->addSaveButton();
         } elseif ($button === 'insert-open') {
             $this->addInsertOpenButton();
         } elseif ($button === 'save-close') {
             $this->addSaveCloseButton();
         } elseif ($button === 'insert-close') {
             $this->addInsertCloseButton();
         } elseif ($button === 'insert') {
             $this->addInsertButton();
         } elseif ($button === 'reload') {
             $this->addReloadButton();
         } elseif ($button === 'reset') {
             $this->addResetButton();
         } elseif ($button === 'view') {
             $this->addViewButton();
         } elseif ($button === 'preview') {
             $this->addPreviewButton();
         } elseif ($button instanceof \Psc\UI\Button) {
             $this->buttons[] = $button;
         } else {
             throw new \InvalidArgumentException('Unbekannter Parameter in array $buttons (1. Parameter) : ' . Code::varInfo($button));
         }
     }
     if ($flags === NULL) {
         $this->flags = self::ALIGN_RIGHT | self::CLEAR;
     } else {
         $this->flags = $flags;
     }
 }
コード例 #6
0
ファイル: ErrorHandler.php プロジェクト: pscheit/psc-cms
 protected function log(\Exception $e, $contextInfo = NULL)
 {
     if ($e instanceof \ErrorException) {
         $errorType = self::$errors[$e->getSeverity()];
     } else {
         $errorType = Code::getClass($e);
     }
     // wir müssen hier den error selbst loggen, da php nichts mehr macht (die faule banane)
     $php = NULL;
     $php .= 'PHP ' . $errorType . ': ' . $e->getMessage() . ' in ' . $e->getFile() . ' on line ' . $e->getLine() . "\n";
     $php .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
     error_log($php, 0);
     /* Debug-Mail */
     $debug = NULL;
     $debug .= '[' . date('d.M.Y H:i:s') . "] ";
     $debug .= $errorType . ': ' . \Psc\Exception::getExceptionText($e, 'text') . "\n";
     if ($e instanceof \Psc\Code\ErrorException) {
         $debug .= "\n" . $e->contextDump;
     }
     if (isset($contextInfo)) {
         $debug .= "\nContextInfo: \n" . $contextInfo;
     }
     if (isset($this->recipient) && !PSC::inTests()) {
         if ($ret = @mail($this->recipient, '[Psc-ErrorHandler] [' . $e->getCode() . '] ' . $e->getMessage(), $debug, 'From: www@' . PSC::getEnvironment()->getHostName() . "\r\n" . 'Content-Type: text/plain; charset=UTF-8' . "\r\n") === FALSE) {
             error_log('[\\Psc\\Code\\ErrorHandler.php:' . __LINE__ . '] Die Fehlerinformationen konnten nicht an den lokalen Mailer übergeben werden.', 0);
         }
     }
 }
コード例 #7
0
 /**
  * Synchronisiert eine Collection von (Datenbank-)Objekten mit einer Collection von Daten / Unique-Kriterien oder Exportieren Objekten
  *
  * Die $fromCollection ist die Collection der bereits hydrierten Objekte. (fertige Tags)
  * die $toCollection ist die noch nicht hydrierte Collection der Objekte die Objekte in $fromCollection repräsentieren (Tag Labels)
  * 
  * zur Hilfe werden zwei Funktionen benötigt.
  * Die hydrierFunktion erstellt aus den Daten asu $toCollection ein Objekt aus $fromCollection ( $label ===> Entity $tag )
  * die hash Funktion erstellt aus einem Objekt von $fromCollection einen Skalar ( Entity $tag => $id )
  *
  * Article und Test beispiel:
  *
  * $fromCollection = $article->getTags();
  * $toCollection = array('Tag1Name','Tag2Name','....');
  *
  * so ungefähr!! muss NULL zurückgeben nicht array
  * $hydrateUniqueObject = function (\stdClass $json) {
  *    return $em->createQueryBuilder()
  *      ->select('tag')->from('Entities\Tag')
  *      ->where('id = :id OR uniqueconstraint = :unique)
  *      ->setParameter(
  *         array(
  *           'id'=>$json->id,
  *           'unique'>$json->label
  *         )
  *       )
  *    ;
  * };
  *
  * $hashObject = function (Tag $tag) {
  *   return $tag->getIdentifier();
  * };
  *
  * @param ArrayCollection $dbCollection die Collection als fertige Objekte aus der Datenbank
  * @param collection $toCollection eine noch nicht hydrierte Collection von Objekten die Objekte in $fromCollection repräsentieren kann
  *
  * @return list($insert,$updates,$deletes) die jeweiligen listen von dispatchten events
  */
 public function process($fromCollection, $toCollection)
 {
     // wir haben keine Ahnung welche Objekte in der $fromCollection und welche in der $toCollection sind
     $fromCollection = \Psc\Code\Code::castArray($fromCollection);
     // damit wir eine copy machen
     $updates = $inserts = $deletes = array();
     $index = array();
     foreach ($toCollection as $toCollectionKey => $toObject) {
         $fromObject = $this->hydrateUniqueObject($toObject, $toCollectionKey);
         // kein objekt konnte hydriert werden
         if ($fromObject === NULL) {
             $inserts[] = $this->dispatchInsert($toObject, array('key' => $toCollectionKey));
             // inserts müssen nicht in den index, da sie nicht im universum gefunden wurden, können sie auch nicht in $fromCollection sein
         } else {
             // objekt hydriert, kann mit korrekter id sein oder matching unique-constraint
             $updates[] = $this->dispatchUpdate($fromObject, array('from' => $fromObject, 'to' => $toObject, 'key' => $toCollectionKey));
             $index[$this->hashObject($fromObject)] = TRUE;
         }
     }
     foreach ($fromCollection as $fromObject) {
         if (!array_key_exists($this->hashObject($fromObject), $index)) {
             // object ist weder ein insert noch ein update
             $deletes[] = $this->dispatchDelete($fromObject);
         }
     }
     return array($inserts, $updates, $deletes);
 }
コード例 #8
0
 /**
  * Erstellt eine neue Rule durch eine Spezifikation (was so quasi alles sein kann)
  *
  * Die Parameter dieser Funktion sind sehr Variabel
  * Möglicherweise ist es einfacher generate[A-Za-z+]Rule zu benutzen
  */
 public static function generateRule($ruleSpecification)
 {
     $rs = $ruleSpecification;
     if (is_string($rs)) {
         if ($rs == 'nes') {
             return new NesValidatorRule();
         }
         if ($rs == 'id') {
             return new IdValidatorRule();
         }
         if ($rs == 'pi' || $rs == 'pint') {
             return new PositiveIntValidatorRule();
         }
         if ($rs == 'array') {
             return new ArrayValidatorRule();
         }
         if ($rs == 'pi0' || $rs == 'pint0') {
             $rule = new PositiveIntValidatorRule();
             $rule->setZeroAllowed(TRUE);
             return $rule;
         }
         if (S::startsWith($rs, '/') && S::endsWith($rs, '/')) {
             return self::generateRegexpRule($rs);
         }
         $c = '\\' . __NAMESPACE__ . '\\' . ucfirst($rs) . 'ValidatorRule';
         if (class_exists($c)) {
             return new $c();
         }
         throw new \Psc\Exception('Unbekannte Parameter für generateRule ' . Code::varInfo($rs));
     }
     if (is_array($rs)) {
         $num = count($rs);
     }
     throw new \Psc\Exception('Unbekannte Parameter für generateRule ' . Code::varInfo($rs));
 }
コード例 #9
0
 protected function getIdentifierCaster(EntityPropertyMeta $identifierMeta)
 {
     if ($identifierMeta->getType() instanceof IntegerType) {
         $idCaster = function ($idString, $debugKey) {
             $id = \Psc\Code\Code::castId($idString, FALSE);
             if ($id === FALSE) {
                 throw new ValidatorRuleException(sprintf("Der Wert '%s' des Schlüssels %s kann nicht zu einer numerischen Id gecastet werden", $idString, $debugKey));
             }
             return $id;
         };
     } elseif ($identifierMeta->getType() instanceof StringType) {
         $idCaster = function ($idString, $debugKey) {
             if (!is_string($idString)) {
                 throw new ValidatorRuleException(sprintf("Der Type '%s' des Schlüssels %s muss ein String sein", gettype($idString), $debugKey));
             }
             if (mb_strlen($idString) == 0) {
                 throw new ValidatorRuleException(sprintf("Der Wert '%s' des Schlüssels %s kann nicht zu einem Identifier gecastet werden", $idString, $debugKey));
             }
             return $idString;
         };
     } else {
         throw new \Psc\Code\NotImplementedException(sprintf('IdCaster für Type %s ist nicht implementiert', $identifierMeta->getType()));
     }
     return $idCaster;
 }
コード例 #10
0
 /**
  * @return list($threadLink, $threadId);
  */
 public function findThread($boardId, Season $season)
 {
     $this->logger->writeln('Suche Thread für ' . $season . ' in board: ' . $boardId);
     $this->req = new URLRequest('http://www.subcentral.de/index.php?page=Board&boardID=' . $boardId, $this->cookieJar);
     $html = $this->req->init()->process();
     /* wir holen uns den richtigen Thread aus den "wichtigen Themen" */
     $dom = xml::doc($html);
     $res = xml::query($dom, '#stickiesStatus table td.columnTopic div.topic p');
     $stickies = array();
     // das sind nicht alle wegen break!
     foreach ($res as $topicP) {
         $topicP = xml::doc($topicP);
         $topicA = A::first(xml::query($topicP, 'a'));
         $title = (string) $topicA->nodeValue;
         $stickies[] = $title;
         $prefix = xml::query($topicP, 'span.prefix strong');
         if (count($prefix) == 1 && $prefix[0]->nodeValue == '[Subs]' && Preg::match($title, '/(Staffel\\s*' . $season->getNum() . '|S0*' . $season->getNum() . ')/i') > 0) {
             $link = $topicA->getAttribute('href');
             $threadId = (int) Preg::qmatch($link, '/threadId=([0-9]+)/');
             break;
         }
     }
     if (!isset($link)) {
         $pe = new SubcentralException('Pfad nicht gefunden: "#stickiesStatus table td.columnTopic div.topic p a" in ' . $this->req->getURL() . ' ' . Code::varInfo($stickies));
         $e = new SubcentralException('Thread für Staffel: ' . $season->getNum() . ' für Serie: ' . $season->getTvShow()->getTitle() . ' nicht gefunden', 0, $pe);
         $this->logger->writeln($e->getMessage());
         $this->logger->writeln($pe->getMessage());
         throw $e;
     }
     $link = 'http://www.subcentral.de/' . $link;
     return array($link, $threadId);
 }
コード例 #11
0
 public function validate($data)
 {
     if (empty($data)) {
         $e = new EmptyDataException();
         $e->setDefaultValue(array());
         throw $e;
     }
     $data = json_decode($data, true);
     if (count($data) == 0) {
         $e = new EmptyDataException();
         $e->setDefaultValue(array());
         throw $e;
     }
     $rep = $this->em->getRepository($this->entityName);
     $collection = $rep->findAllByIds($data, $this->idName);
     // überspringt dies fehlende Ids?
     // sortieren nach der Data List (da findAllByIds das nicht tut, und das ist auch gut so)
     $getter = \Psc\Code\Code::castGetter($this->idName);
     $keys = array_flip($data);
     usort($collection, function ($entityA, $entityB) use($keys, $getter) {
         $keyA = $keys[$getter($entityA)];
         $keyB = $keys[$getter($entityB)];
         if ($keyA === $keyB) {
             return 0;
         }
         return $keyA > $keyB ? 1 : -1;
     });
     if (count($collection) == count($data)) {
         return $collection;
     } else {
         throw new \Psc\Exception('Unexpected: Es wurden: ' . count($collection) . ' IDs hydriert, aber ' . count($data) . ' IDs angegeben.');
     }
 }
コード例 #12
0
ファイル: BaseEntity.php プロジェクト: pscheit/psc-cms
 /**
  * Ruft den Getter für das Feld $field auf dem Entity auf
  *
  * @param string $field der Name des Feldes in CamelCase
  * @return mixed
  */
 public function callGetter($field)
 {
     $f = 'get' . ucfirst($field);
     if (!method_exists($this, $f)) {
         throw new \InvalidArgumentException($f . '() existiert nicht in ' . \Psc\Code\Code::getClass($this));
     }
     return $this->{$f}();
 }
コード例 #13
0
 public function process($fromCollection, $toCollection)
 {
     // der genericCollectionSynchronizer braucht ArrayCollections
     $fromCollection = Code::castCollection($fromCollection);
     $toCollection = Code::castCollection($toCollection);
     // die defaults sind: compare nach object, hashe nach identifier, und die sind prima für uns
     $this->innerSynchronizer->process($fromCollection, $toCollection);
 }
コード例 #14
0
ファイル: UserManager.php プロジェクト: pscheit/psc-cms
 public function get($identifier)
 {
     try {
         return $this->repository->hydrate($identifier);
     } catch (\Psc\Doctrine\EntityNotFoundException $e) {
         throw new NoUserException('User mit dem Identifier: ' . Code::varInfo($identifier) . ' nicht gefunden.', 0, $e);
     }
 }
コード例 #15
0
ファイル: ClassReader.php プロジェクト: pscheit/psc-cms
 /**
  * @return Webforge\Common\System\File
  */
 protected function getGClassFromFile()
 {
     $project = \Psc\PSC::getProject();
     $gClass = new GClass(Code::mapFileToClass($this->file, $project->dir('lib')));
     $gClass->setSrcFileName((string) $this->file);
     // damit wir wirklich fremde sourcen angeben können
     return $gClass;
 }
コード例 #16
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');
     }
 }
コード例 #17
0
ファイル: ProcessBuilder.php プロジェクト: pscheit/psc-cms
 public function escapeFor($type)
 {
     \Psc\Code\Code::value($type, self::WINDOWS, self::UNIX);
     if ($this->escapeFor != NULL && $type != $this->escapeFor && count($this->args) > 0) {
         throw new \RuntimeException('You switched to another escapeFor Mode, but you have already added arguments (through constructor?). Use escapeFor as last Argument from create/construct or as first chain-command');
     }
     $this->escapeFor = $type;
     return $this;
 }
コード例 #18
0
ファイル: EntityManagerTest.php プロジェクト: pscheit/psc-cms
 /**
  * @dataProvider provideMockCollections
  */
 public function testSetMockCollection($colls)
 {
     $entity = $this->createTestEntity();
     foreach ($colls as $coll) {
         $set = \Psc\Code\Code::castSetter($coll);
         $this->assertChainable($set($this->emm, array($entity)));
         $this->assertEquals(array($entity), $this->emm->getMockCollection($coll)->toArray());
     }
 }
コード例 #19
0
ファイル: DatabaseTest.php プロジェクト: pscheit/psc-cms
 public function setUpFixtures()
 {
     // overload this
     if (\Psc\Code\Code::isTraversable($this->fixtures)) {
         foreach ($this->fixtures as $fixture) {
             $this->dcFixtures->add($fixture);
         }
     }
 }
コード例 #20
0
ファイル: SetMeta.php プロジェクト: pscheit/psc-cms
 /**
  * @param array Webforge\Types[] Schlüssel sind Namen der Felder (Ebenen getrennt mit .), Werte sind Webforge\Types\Type-Objekte
  */
 public function addTypesFromArray(array $types)
 {
     foreach ($types as $field => $type) {
         if (!$type instanceof Type) {
             throw new TypeExpectedException('Instances from Type as values from the array expected. ' . Code::varInfo($type) . ' was provided.');
         }
         $this->setFieldType($field, $type);
     }
     return $this;
 }
コード例 #21
0
ファイル: TestCase.php プロジェクト: pscheit/psc-cms
 protected function assertTypeMapsComponent($class, WebforgeType $type, $mapper = NULL)
 {
     $mapper = $mapper ?: new ComponentMapper();
     $this->assertInstanceOf('Psc\\CMS\\Component', $component = $mapper->inferComponent($type));
     if ($class !== 'any') {
         $class = Code::expandNamespace($class, 'Psc\\UI\\Component');
         $this->assertInstanceOf($class, $component);
     }
     return $component;
 }
コード例 #22
0
ファイル: Helper.php プロジェクト: pscheit/psc-cms
 /**
  * $message->setTo(self::recipient('*****@*****.**'));
  * 
  * @return korrektes Format für Message::set(From|To|Bcc|Cc)
  */
 public static function recipient($recipient)
 {
     if (is_string($recipient)) {
         return $recipient;
     }
     if (is_array($recipient)) {
         return $recipient;
     }
     // @TODO checks?
     throw new Exception('Unbekannter Parameter: ' . Code::varInfo($recipient));
 }
コード例 #23
0
ファイル: DoublesManager.php プロジェクト: pscheit/psc-cms
 /**
  * @return Psc\Net\HTTP\Request
  */
 public function createHTTPRequest($methodString, $resource, $GET = array(), $POST = array(), $COOKIE = array(), $accept = NULL)
 {
     \Psc\Code\Code::value($methodString, 'GET', 'POST');
     $project = \Psc\PSC::getProject();
     $baseUrl = $project->getHostUrl('base');
     $SERVER = array('HTTP_HOST' => $baseUrl->getHost(), 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 6.0; rv:7.0.1) Gecko/20100101 Firefox/7.0.1', 'HTTP_ACCEPT' => $accept ?: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5', 'HTTP_ACCEPT_ENCODING' => 'gzip, deflate', 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_CONNECTION' => 'keep-alive', 'SERVER_NAME' => $baseUrl->getHost(), 'DOCUMENT_ROOT' => (string) $project->dir('www'), 'REDIRECT_QUERY_STRING' => 'request=' . $resource, 'REDIRECT_URL' => $resource, 'GATEWAY_INTERFACE' => 'CGI/1.1', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'REQUEST_METHOD' => $methodString, 'QUERY_STRING' => 'request=' . $resource, 'REQUEST_URI' => $resource, 'SCRIPT_NAME' => '/api.php', 'PHP_SELF' => '/api.php', 'REQUEST_TIME' => time());
     //$request = create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null)
     $request = SfRequest::create((string) $baseUrl . '/' . ltrim($resource, '/'), $methodString, $methodString === 'POST' ? $POST : $GET, $COOKIE, array(), $SERVER);
     $request = Request::infer($request);
     return $request;
 }
コード例 #24
0
 public function export()
 {
     $export = array();
     foreach ($this->toArray() as $key => $element) {
         if (!$element instanceof Exportable) {
             throw new Exception('Jedes Element einer ArrayExportCollection muss ein Exportable sein. ' . Code::varInfo($element));
         }
         $export[$key] = $element->export();
     }
     return $export;
 }
コード例 #25
0
ファイル: BasicImage2.php プロジェクト: pscheit/psc-cms
 protected function getThumbnailFormat($format)
 {
     if (array_key_exists($format, $this->formats)) {
         $arguments = $this->formats[$format];
         $options = array();
         if (count($arguments) == 4) {
             $options = array_pop($arguments);
         }
         return (object) array('arguments' => $arguments, 'options' => $options);
     }
     throw new \Psc\Exception('Unbekanntes Format: ' . Code::varInfo($format));
 }
コード例 #26
0
ファイル: Hydrator.php プロジェクト: pscheit/psc-cms
 /**
  *
  * $hydrator = new Hydrator('FoodTag', $doctrinePackage);
  * $tags = $hydrator->byList(array('hot','special','spicy'), 'label');
  * 
  * @return array
  */
 public function byList(array $list, $field, $checkCardinality = TRUE, &$found = NULL)
 {
     if ($list == NULL) {
         return array();
     }
     $result = $this->getRepository()->findBy(array($field => $list));
     $found = count($result);
     if ($checkCardinality && $found != count($list)) {
         throw new \Psc\Exception('Es konnten nicht alle Felder aus der Liste geladen werden. Gefunden: ' . $found . ' in der Liste waren aber: ' . count($list) . ' Liste: ' . Code::varInfo($list));
     }
     return $result;
 }
コード例 #27
0
ファイル: ResponseHeader.php プロジェクト: pscheit/psc-cms
 public function setCode($code, $reason = NULL)
 {
     if (!is_integer($code)) {
         throw new \InvalidArgumentException('Code muss ein Integer sein: ' . Code::varInfo($code));
     }
     $this->code = $code;
     if (!array_key_exists($this->code, self::$reasons)) {
         throw new \InvalidArgumentException('Response Code: ' . $code . ' ist nicht bekannt');
     }
     $this->reason = $reason ?: self::$reasons[$this->code];
     return $this;
 }
コード例 #28
0
ファイル: EntityFormPanel.php プロジェクト: pscheit/psc-cms
 protected function doInit()
 {
     // damit die components der form innerhalb des formpanels an der richtigen stelle stehen
     // holen wir uns diese aus der Componentsform
     foreach ($this->form->getComponents() as $key => $component) {
         try {
             $this->content['component' . $key] = $component->html();
         } catch (\Psc\Exception $e) {
             throw new \Psc\Exception('Component ' . Code::getClass($component) . ' verursachte einen Fehler beim HTML-Erzeugen', 0, $e);
         }
     }
     parent::doInit();
 }
コード例 #29
0
ファイル: ServiceBase.php プロジェクト: pscheit/psc-cms
 public function assertRoutingException(Closure $c, $debugMessage = '')
 {
     try {
         $c();
     } catch (\Exception $e) {
         if ($e instanceof \Psc\CMS\Service\ControllerRouteException || $e instanceof \Psc\Net\HTTP\HTTPException || $e instanceof \Psc\Net\RequestMatchingException) {
             return;
         } else {
             $this->fail('Exception: Psc\\CMS\\Service\\ControllerRouteException oder Psc\\Net\\RequestMatchingException erwartet. Es wurde aber ' . \Psc\Code\Code::getClass($e) . ' gecatched. (ExceptionMessage: ' . $e->getMessage() . ') ' . $debugMessage);
         }
     }
     $this->fail('Exception: Psc\\CMS\\Service\\ControllerRouteException oder Psc\\Net\\RequestMatchingException erwartet. Es wurde aber keine gecatched. ' . $debugMessage);
 }
コード例 #30
0
 public function validate($data)
 {
     if ($data === NULL) {
         throw EmptyDataException::factory(array());
     }
     $data = Code::castArray($data);
     if (count($data) == 0) {
         throw EmptyDataException::factory(array());
     }
     if (count($data) > 0) {
         return $data;
     }
     throw new \Psc\Exception('Konnte nicht validiert werden');
 }