コード例 #1
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;
 }
コード例 #2
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;
 }
コード例 #3
0
ファイル: Price.php プロジェクト: pscheit/psc-cms
 public function convertTo($type, $precision = NULL)
 {
     Code::value($type, self::NET, self::GROSS, self::TAX);
     if ($type === self::GROSS && $this->tax !== -1) {
         $price = $this->net * (1 + $this->tax);
     } elseif ($type === self::TAX) {
         if ($this->tax === -1) {
             return 0;
         }
         $price = $this->net * $this->tax;
     } else {
         $price = $this->net;
     }
     return round($price, $precision ?: $this->precision);
 }
コード例 #4
0
 /**
  * @return Psc\Doctrine\Annotation
  */
 protected function assertHasRelationAnnotation($expectedName, $expectedProperties, DocBlock $actualDocBlock)
 {
     Code::value($expectedName, 'OneToMany', 'ManyToOne', 'OneToOne', 'ManyToMany');
     $this->assertEquals(Annotation::createDC($expectedName, $expectedProperties), $annotation = $this->assertHasDCAnnotation($actualDocBlock, $expectedName));
     return $annotation;
 }
コード例 #5
0
ファイル: Request.php プロジェクト: pscheit/psc-cms
 public function setMethod($method)
 {
     Code::value($method, self::GET, self::POST, self::PUT, self::DELETE, self::PATCH);
     $this->method = $method;
 }
コード例 #6
0
ファイル: EntityBuilder.php プロジェクト: pscheit/psc-cms
 /**
  * Legacy Interface für den ModelCompiler (für den ersten Wurf)
  * 
  * erstellt eine Relation und ruft direkt buildRelation auf
  * @return EntityRelation
  */
 public function createRelation($relationType, EntityRelationMeta $source, EntityRelationMeta $target, $side = NULL, $updateOtherSide = true)
 {
     Code::value($relationType, self::RELATION_MANY_TO_MANY, self::RELATION_MANY_TO_ONE, self::RELATION_ONE_TO_MANY, self::RELATION_ONE_TO_ONE);
     Code::value($side, self::SIDE_OWNING, self::SIDE_INVERSE, NULL);
     // Parameter übersetzen in constructor parameter von relation
     if ($side !== NULL) {
         $direction = EntityRelation::BIDIRECTIONAL;
         $whoIsOwningSide = $side === self::SIDE_OWNING ? EntityRelation::SOURCE : EntityRelation::TARGET;
     } else {
         $direction = EntityRelation::UNIDIRECTIONAL;
         $whoIsOwningSide = NULL;
     }
     $relation = new EntityRelation($source, $target, $relationType, $direction, $whoIsOwningSide);
     $this->buildRelation($relation);
     return $relation;
 }
コード例 #7
0
ファイル: AjaxMeta.php プロジェクト: pscheit/psc-cms
 /**
  * @param const $method
  * @chainable
  */
 protected function setMethod($method)
 {
     Code::value($method, self::GET, self::POST, self::PUT, self::DELETE);
     $this->method = $method;
     return $this;
 }
コード例 #8
0
ファイル: ComponentsForm.php プロジェクト: pscheit/psc-cms
 public function sortComponentsBy($property)
 {
     Code::value($property, 'formName', 'formValue', 'formLabel', 'componentName');
     $getter = Code::castGetter($property);
     $sorting = function ($c1, $c2) use($getter) {
         return strcmp($getter($c1), $getter($c2));
     };
     $this->sortComponents($sorting);
     return $this;
 }
コード例 #9
0
ファイル: Form.php プロジェクト: pscheit/psc-cms
 public static function attachLabel($element, $label, $type = self::LABEL_TOP)
 {
     Code::value($type, self::LABEL_TOP, self::LABEL_CHECKBOX);
     if ($label != NULL) {
         $element->templateContent->label = fHTML::label($label, $element)->addClass('\\Psc\\label');
         if ($type == self::LABEL_TOP) {
             $element->templatePrepend('%label%');
             // nicht überschreiben sondern prependen
         }
         if ($type == self::LABEL_CHECKBOX) {
             $element->template = '%self% %label%';
             $element->templateContent->label->addClass('checkbox-label');
         }
     }
     return $element;
 }
コード例 #10
0
 /**
  * @param string $valueType
  */
 public function setValueType($valueType)
 {
     Code::value($valueType, self::COLLECTION_VALUED, self::SINGLE_VALUED);
     $this->valueType = $valueType;
     return $this;
 }
コード例 #11
0
ファイル: ContactFormMailer.php プロジェクト: pscheit/psc-cms
 /**
  * @param string $mode
  * @chainable
  */
 public function setMode($mode)
 {
     Code::value($mode, self::MODE_LOCAL_MAIL, self::MODE_NULL, self::MODE_SMTP);
     $this->mode = $mode;
     return $this;
 }
コード例 #12
0
ファイル: ActionMeta.php プロジェクト: pscheit/psc-cms
 /**
  * @chainable
  */
 protected function setType($type)
 {
     Code::value($type, self::SPECIFIC, self::GENERAL);
     $this->type = $type;
     return $this;
 }
コード例 #13
0
ファイル: ServiceResponse.php プロジェクト: pscheit/psc-cms
 /**
  * @param const $status Service::OK|Service::ERROR usw
  * @chainable
  */
 public function setStatus($status)
 {
     Code::value($status, Service::OK, Service::ERROR);
     $this->status = $status;
     return $this;
 }
コード例 #14
0
 /**
  * @param $type normal|hydration
  * @return Psc\Doctrine\EntityCollectionSynchronizer
  */
 protected function getSynchronizerFor($collectionPropertyName, $type = 'normal')
 {
     Code::value($type, 'normal', 'hydration');
     if ($type === 'hydration') {
         $c = 'Psc\\Doctrine\\PersistentCollectionSynchronizer';
     } else {
         $c = 'Psc\\Doctrine\\CollectionSynchronizer';
     }
     return $c::createFor($this->getEntityName(), $collectionPropertyName, $this->dc);
 }
コード例 #15
0
ファイル: CodeTest.php プロジェクト: pscheit/psc-cms
 public function testValue()
 {
     $ex = 'Psc\\Code\\WrongValueException';
     $this->assertEquals('eins', Code::value('eins', 'eins', 'zwei', 'drei'));
     $this->assertEquals('zwei', Code::value('zwei', 'eins', 'zwei', 'drei'));
     $this->assertEquals('drei', Code::value('drei', 'eins', 'zwei', 'drei'));
     $this->assertException($ex, function () {
         Code::value(NULL, 'eins', 'zwei', 'drei');
     });
     $this->assertException($ex, function () {
         Code::value('notexistent', 'eins', 'zwei', 'drei');
     });
 }
コード例 #16
0
ファイル: Form.php プロジェクト: pscheit/psc-cms
 /**
  * @param string $method
  * @chainable
  */
 public function setMethod($method)
 {
     Code::value($method, 'post', 'get');
     $this->method = $method;
     return $this;
 }
コード例 #17
0
ファイル: EntityRelation.php プロジェクト: pscheit/psc-cms
 /**
  * @param const $onDelete
  */
 public function setOnDelete($onDelete)
 {
     Code::value($onDelete, self::CASCADE, self::SET_NULL);
     $this->onDelete = $onDelete;
     return $this;
 }
コード例 #18
0
 /**
  * @param const $dependencyInjection
  * @chainable
  */
 public function setDependencyInjection($dependencyInjection)
 {
     // @TODO self::DEPENDENCY_INJECTION_GETTER,
     Code::value($dependencyInjection, self::DEPENDENCY_INJECTION_CONSTRUCTOR, self::DEPENDENCY_INJECTION_NONE);
     $this->dependencyInjection = $dependencyInjection;
     return $this;
 }
コード例 #19
0
ファイル: ClassWriter.php プロジェクト: pscheit/psc-cms
 public function setUseStyle($style)
 {
     Code::value($style, self::USE_STYLE_LINES, self::USE_STYLE_BLOCK);
     $this->useStyle = $style;
     return $this;
 }
コード例 #20
0
ファイル: ServiceRequest.php プロジェクト: pscheit/psc-cms
 /**
  * @param const $type Service::
  * @chainable
  */
 public function setType($type)
 {
     Code::value($type, Service::GET, Service::POST, Service::PUT, Service::DELETE, Service::PATCH);
     $this->type = $type;
     return $this;
 }