/** * Overload method access * * Creates the following virtual methods: * - appendStylesheet($href, $media, $conditionalStylesheet, $extras) * - offsetSetStylesheet($index, $href, $media, $conditionalStylesheet, $extras) * - prependStylesheet($href, $media, $conditionalStylesheet, $extras) * - setStylesheet($href, $media, $conditionalStylesheet, $extras) * - appendAlternate($href, $type, $title, $extras) * - offsetSetAlternate($index, $href, $type, $title, $extras) * - prependAlternate($href, $type, $title, $extras) * - setAlternate($href, $type, $title, $extras) * * Items that may be added in the future: * - Navigation? need to find docs on this * - public function appendStart() * - public function appendContents() * - public function appendPrev() * - public function appendNext() * - public function appendIndex() * - public function appendEnd() * - public function appendGlossary() * - public function appendAppendix() * - public function appendHelp() * - public function appendBookmark() * - Other? * - public function appendCopyright() * - public function appendChapter() * - public function appendSection() * - public function appendSubsection() * * @param mixed $method * @param mixed $args * @return void */ public function __call($method, $args) { if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<type>Stylesheet|Alternate)$/', $method, $matches)) { $argc = count($args); $action = $matches['action']; $type = $matches['type']; $index = null; if ('offsetSet' == $action) { if (0 < $argc) { $index = array_shift($args); --$argc; } } if (1 > $argc) { $e = new View\Exception(sprintf('%s requires at least one argument', $method)); $e->setView($this->view); throw $e; } if (is_array($args[0])) { $item = $this->createData($args[0]); } else { $dataMethod = 'createData' . $type; $item = $this->{$dataMethod}($args); } if ($item) { if ('offsetSet' == $action) { $this->offsetSet($index, $item); } else { $this->{$action}($item); } } return $this; } return parent::__call($method, $args); }
/** * Overload method access * * Allows the following 'virtual' methods: * - appendName($keyValue, $content, $modifiers = array()) * - offsetGetName($index, $keyValue, $content, $modifers = array()) * - prependName($keyValue, $content, $modifiers = array()) * - setName($keyValue, $content, $modifiers = array()) * - appendHttpEquiv($keyValue, $content, $modifiers = array()) * - offsetGetHttpEquiv($index, $keyValue, $content, $modifers = array()) * - prependHttpEquiv($keyValue, $content, $modifiers = array()) * - setHttpEquiv($keyValue, $content, $modifiers = array()) * * @param string $method * @param array $args * @return \Zend\View\Helper\HeadMeta * @throws Exception\BadMethodCallException */ public function __call($method, $args) { if (preg_match('/^(?P<action>set|(pre|ap)pend|offsetSet)(?P<type>Name|HttpEquiv)$/', $method, $matches)) { $action = $matches['action']; $type = $this->_normalizeType($matches['type']); $argc = count($args); $index = null; if ('offsetSet' == $action) { if (0 < $argc) { $index = array_shift($args); --$argc; } } if (2 > $argc) { throw new Exception\BadMethodCallException('Too few arguments provided; requires key value, and content'); } if (3 > $argc) { $args[] = array(); } $item = $this->createData($type, $args[0], $args[1], $args[2]); if ('offsetSet' == $action) { return $this->offsetSet($index, $item); } $this->{$action}($item); return $this; } return parent::__call($method, $args); }
/** * Overload method access * * Allows the following method calls: * - appendFile($src, $type = 'text/javascript', $attrs = array()) * - offsetSetFile($index, $src, $type = 'text/javascript', $attrs = array()) * - prependFile($src, $type = 'text/javascript', $attrs = array()) * - setFile($src, $type = 'text/javascript', $attrs = array()) * - appendScript($script, $type = 'text/javascript', $attrs = array()) * - offsetSetScript($index, $src, $type = 'text/javascript', $attrs = array()) * - prependScript($script, $type = 'text/javascript', $attrs = array()) * - setScript($script, $type = 'text/javascript', $attrs = array()) * * @param string $method Method to call * @param array $args Arguments of method * @return \Zend\View\Helper\HeadScript * @throws \Zend\View\Exception if too few arguments or invalid method */ public function __call($method, $args) { if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<mode>File|Script)$/', $method, $matches)) { if (1 > count($args)) { $e = new View\Exception(sprintf('Method "%s" requires at least one argument', $method)); $e->setView($this->view); throw $e; } $action = $matches['action']; $mode = strtolower($matches['mode']); $type = 'text/javascript'; $attrs = array(); if ('offsetSet' == $action) { $index = array_shift($args); if (1 > count($args)) { $e = new View\Exception(sprintf('Method "%s" requires at least two arguments, an index and source', $method)); $e->setView($this->view); throw $e; } } $content = $args[0]; if (isset($args[1])) { $type = (string) $args[1]; } if (isset($args[2])) { $attrs = (array) $args[2]; } switch ($mode) { case 'script': $item = $this->createData($type, $attrs, $content); if ('offsetSet' == $action) { $this->offsetSet($index, $item); } else { $this->{$action}($item); } break; case 'file': default: if (!$this->_isDuplicate($content)) { $attrs['src'] = $content; $item = $this->createData($type, $attrs); if ('offsetSet' == $action) { $this->offsetSet($index, $item); } else { $this->{$action}($item); } } break; } return $this; } return parent::__call($method, $args); }
/** * Overload method calls * * Allows the following method calls: * - appendStyle($content, $attributes = array()) * - offsetSetStyle($index, $content, $attributes = array()) * - prependStyle($content, $attributes = array()) * - setStyle($content, $attributes = array()) * * @param string $method * @param array $args * @return void * @throws Exception\BadMethodCallException When no $content provided or invalid method */ public function __call($method, $args) { if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(Style)$/', $method, $matches)) { $index = null; $argc = count($args); $action = $matches['action']; if ('offsetSet' == $action) { if (0 < $argc) { $index = array_shift($args); --$argc; } } if (1 > $argc) { throw new Exception\BadMethodCallException(sprintf('Method "%s" requires minimally content for the stylesheet', $method)); } $content = $args[0]; $attrs = array(); if (isset($args[1])) { $attrs = (array) $args[1]; } $item = $this->createData($content, $attrs); if ('offsetSet' == $action) { $this->offsetSet($index, $item); } else { $this->{$action}($item); } return $this; } return parent::__call($method, $args); }