public function __construct(Identifier $page)
 {
     if (!$page->of(WebPage::getIdentifier())) {
         throw new \InvalidArgumentException(sprintf('RestartRequestOnPageException expects a web page identifier, %s given.', $page->getFullyQualifiedName()));
     }
     $this->page = $page;
     parent::__construct('RestartRequestOnPageException');
 }
Пример #2
0
 /**
  * @param Board $board
  * @param int $depth
  */
 protected function build(Board $board, $depth)
 {
     $board->write('INSERT INTO ');
     $this->table->build($board, $depth + 1);
     $board->write(" (");
     $this->columns->build($board, $depth + 1);
     $board->write(")\n");
     $this->data->build($board, $depth + 1);
 }
 public function addWorkflowDefinition(Identifier $id)
 {
     if ($id->getType() != c\T::WORKFLOWDEFINITION) {
         throw new \Exception(S_SPAN . "The identifier is unacceptable." . E_SPAN);
     }
     if ($this->hasWorkflowDefinition($id->getId())) {
         return $this;
     }
     $this->workflow_definitions[] = $id;
     return $this;
 }
Пример #4
0
 /**
  * @param Board $board
  * @param int $depth
  */
 protected function build(Board $board, $depth)
 {
     $board->write('DELETE FROM ');
     $this->table->build($board, $depth + 1);
     $where = $this->where;
     if ($where) {
         $board->write("\n");
         $board->write('WHERE');
         $board->write($where->isBlock() ? "\n" : " ");
         $where->build($board, $depth + 1);
     }
 }
Пример #5
0
 public function isValid($value)
 {
     $messages = [];
     $validator = new Identifier();
     $result = true;
     foreach ($value as $name) {
         $validatorResult = $validator->isValid($name);
         if (!$validatorResult->getResult()) {
             $result = false;
             foreach ($validatorResult->getMessages() as $message) {
                 $messages[] = $name . ' not valid. ' . $message;
             }
         }
     }
     return new ValidatorResult($result, $messages);
 }
Пример #6
0
 /**
  * Modify and cache application response
  *
  * @param \Magento\Framework\App\Response\Http $response
  * @return void
  */
 public function process(\Magento\Framework\App\Response\Http $response)
 {
     if (preg_match('/public.*s-maxage=(\\d+)/', $response->getHeader('Cache-Control')['value'], $matches)) {
         $maxAge = $matches[1];
         $response->setNoCacheHeaders();
         if ($response->getHttpResponseCode() == 200 && ($this->request->isGet() || $this->request->isHead())) {
             $tagsHeader = $response->getHeader('X-Magento-Tags');
             $tags = $tagsHeader ? explode(',', $tagsHeader['value']) : array();
             $response->clearHeader('Set-Cookie');
             $response->clearHeader('X-Magento-Tags');
             if (!headers_sent()) {
                 header_remove('Set-Cookie');
             }
             $this->cache->save(serialize($response), $this->identifier->getValue(), $tags, $maxAge);
         }
     }
 }
 public function resolve(Request $request)
 {
     $resourceString = $request->getParameter('res');
     $resourceArray = explode(':', $resourceString);
     $identifier = Identifier::forName(str_replace('.', '\\', $resourceArray[0]));
     $file = $resourceArray[1];
     $resource = new ResourceReference($file, $identifier);
     return new ResourceRequestTarget($resource);
 }
Пример #8
0
 public function getChoiceGroup()
 {
     $choice = null;
     $callback = function (&$component) use(&$choice) {
         $choice = $component;
         return Component::VISITOR_STOP_TRAVERSAL;
     };
     $this->visitParents(Identifier::forName('picon\\ChoiceGroup'), $callback);
     return $choice;
 }
Пример #9
0
 /**
  * Retrieve a unique identifier for object instance
  * @param mixed $object
  * @return string
  */
 protected static function identify($object)
 {
     foreach (self::$uids as $uid => $e) {
         if ($e === $object) {
             return $uid;
         }
     }
     $uid = Identifier::identify($object);
     self::$uids[$uid] = $object;
     return $uid;
 }
Пример #10
0
 public function containsTarget(Identifier $contains)
 {
     foreach ($this->targetStack as $target) {
         $identifier = Identifier::forObject($target);
         if ($identifier->of($contains)) {
             return true;
         }
     }
     return false;
 }
Пример #11
0
 /**
  * Throw an exception if the object identifier is not a subclass or implementer of expected
  * @param Identifier $object
  * @param Identifier $expected
  * @param type $argName 
  */
 public static function identifierOf(Identifier $object, Identifier $expected, $argName)
 {
     if (!$object->of($expected)) {
         throw new \InvalidArgumentException(sprintf("%s expected argument %s to be an identifier of %s, actual %s", self::getCallingMethod(), $argName, $expected->getFullyQualifiedName(), $object->getFullyQualifiedName()));
     }
 }
Пример #12
0
 public function testDepth()
 {
     $syntax = new Syntax();
     $this->assertEquals(1, $syntax->depth());
     $rule = new Rule($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $rule->depth());
     $syntax->addChild($rule);
     $this->assertEquals(2, $syntax->depth());
     $seq = new Sequence($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $seq->depth());
     $rule->addChild($seq);
     $this->assertEquals(2, $rule->depth());
     $this->assertEquals(3, $syntax->depth());
     $ident = new Identifier($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $ident->depth());
     $seq->addChild($ident);
     $this->assertEquals(2, $seq->depth());
     $this->assertEquals(3, $rule->depth());
     $this->assertEquals(4, $syntax->depth());
     $loop = new Loop($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $loop->depth());
     $seq->addChild($loop);
     $this->assertEquals(2, $seq->depth());
     $this->assertEquals(3, $rule->depth());
     $this->assertEquals(4, $syntax->depth());
     $term = new Terminal($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $term->depth());
     $loop->addChild($term);
     $this->assertEquals(2, $loop->depth());
     $this->assertEquals(3, $seq->depth());
     $this->assertEquals(4, $rule->depth());
     $this->assertEquals(5, $syntax->depth());
 }
 /**
  * @return Identifier
  **/
 public final function obtainSequence($sequence)
 {
     $id = Identifier::create();
     $this->sequencePool[$sequence][] = $id;
     return $id;
 }
Пример #14
0
 /**
  * @param Identifier $Identifier
  *
  * @return bool
  */
 public function hasConnection(Identifier $Identifier)
 {
     return isset(self::$Register[$Identifier->getIdentifier()]);
 }
Пример #15
0
 public static function getIdentifier()
 {
     return Identifier::forName(get_called_class());
 }
Пример #16
0
 /**
  * @todo this should use a request target
  * @param Identifier $page
  * @return type 
  */
 public function urlForPage(Identifier $page)
 {
     if (is_subclass_of($page->getFullyQualifiedName(), WebPage::getIdentifier()->getFullyQualifiedName())) {
         return $this->getRequest()->getRootPath() . $page->getFullyQualifiedName();
     }
     throw new \InvalidArgumentException(sprintf("Expected identifier of a web page, actual %s", $page->getFullyQualifiedName()));
 }
Пример #17
0
 public function testDepth()
 {
     $ident = new Identifier($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node'));
     $this->assertEquals(1, $ident->depth());
 }
Пример #18
0
 public function mount($path, Identifier $page)
 {
     if (!$page->of(WebPage::getIdentifier())) {
         throw new \InvalidArgumentException('Expected an identifier of a web page');
     }
     if ($this->isMounted($path)) {
         throw new \InvalidArgumentException(sprintf('The path %s is already mounted', $path));
     }
     $this->addToPath($path, $page->getFullyQualifiedName());
     $this->mountedPages[] = $path;
 }
Пример #19
0
 /**
  * Checks whether this identifier is the same or is a child of the given 
  * identifier. Checks for equality, sub class or interface implementation
  * @param Identifier $object The identifier to check against
  * @return boolean  
  */
 public function of($object)
 {
     if (!$object instanceof Identifier) {
         return false;
     }
     return in_array($this->getFullyQualifiedName(), class_implements($object->getFullyQualifiedName())) || is_subclass_of($this->getFullyQualifiedName(), $object->getFullyQualifiedName()) || $object->getFullyQualifiedName() == $this->getFullyQualifiedName();
 }