Esempio n. 1
0
 /**
  *
  * @param array $options
  * @return \webignition\RobotsTxt\DirectiveList\DirectiveList 
  */
 public function getDirectiveList($options = array())
 {
     $directives = $this->sourceDirectiveList->get();
     if (isset($options['field'])) {
         foreach ($directives as $directiveIndex => $directive) {
             /* @var $directive \webignition\RobotsTxt\Directive\Directive */
             if (!$directive->is($options['field'])) {
                 unset($directives[$directiveIndex]);
             }
         }
     }
     if (isset($options['value'])) {
         foreach ($directives as $directiveIndex => $directive) {
             /* @var $directive \webignition\RobotsTxt\Directive\Directive */
             if ((string) $directive->getValue() != $options['value']) {
                 unset($directives[$directiveIndex]);
             }
         }
     }
     $directiveList = new \webignition\RobotsTxt\DirectiveList\DirectiveList();
     foreach ($directives as $directive) {
         $directiveList->add((string) $directive);
     }
     return $directiveList;
 }
 /**
  *
  * @return array
  */
 public function get()
 {
     $userAgents = parent::get();
     if (count($userAgents) === 0) {
         $defaultUserAgentDirective = new \webignition\RobotsTxt\UserAgentDirective\UserAgentDirective();
         $defaultUserAgentDirective->parse('user-agent:*');
         $userAgents[] = $defaultUserAgentDirective;
     }
     return $userAgents;
 }