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');
 }
Exemple #2
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()));
     }
 }
Exemple #3
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()));
 }
Exemple #4
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;
 }
Exemple #5
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();
 }