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'); }
/** * @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; }
/** * @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); } }
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); }
/** * 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); }
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; }
/** * 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; }
public function containsTarget(Identifier $contains) { foreach ($this->targetStack as $target) { $identifier = Identifier::forObject($target); if ($identifier->of($contains)) { return true; } } return false; }
/** * 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())); } }
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; }
/** * @param Identifier $Identifier * * @return bool */ public function hasConnection(Identifier $Identifier) { return isset(self::$Register[$Identifier->getIdentifier()]); }
public static function getIdentifier() { return Identifier::forName(get_called_class()); }
/** * @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())); }
public function testDepth() { $ident = new Identifier($this->getMock('de\\weltraumschaf\\ebnf\\ast\\Node')); $this->assertEquals(1, $ident->depth()); }
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; }
/** * 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(); }