has() public method

Returns if there is any value for the given property.
public has ( string $property )
$property string Property name.
示例#1
0
 /**
  *	Builds an HTML code from the given media's properties to fill its
  *	'html' property.
  *
  *	@param Essence\Media $Media A reference to the Media.
  *	@param array $options Options.
  */
 public function complete(Media $Media, array $options = [])
 {
     if ($Media->has('html')) {
         return;
     }
     $title = htmlspecialchars($Media->get('title', $Media->url));
     $description = $Media->has('description') ? htmlspecialchars($Media->description) : $title;
     $options += $this->_defaults;
     $width = $Media->setDefault('width', $options['width']);
     $height = $Media->setDefault('height', $options['height']);
     switch ($Media->type) {
         // builds an <img> tag pointing to the photo
         case 'photo':
             $Media->set('html', sprintf('<img src="%s" alt="%s" width="%d" height="%d" />', $Media->url, $description, $width, $height));
             break;
             // builds an <iframe> tag pointing to the video
         // builds an <iframe> tag pointing to the video
         case 'video':
             $Media->set('html', sprintf('<iframe src="%s" width="%d" height="%d" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen />', $Media->url, $width, $height));
             break;
             // builds an <a> tag pointing to the original resource
         // builds an <a> tag pointing to the original resource
         default:
             $Media->set('html', sprintf('<a href="%s" alt="%s">%s</a>', $Media->url, $description, $title));
             break;
     }
 }
 /**
  *
  */
 public function testPresent()
 {
     $Media = new Media();
     $this->assertFalse($Media->has('foo'));
     $Media = $this->Completer->present($Media);
     $this->assertEquals('bar', $Media->get('foo'));
 }
示例#3
0
 /**
  *	{@inheritDoc}
  */
 public function present(Media $Media)
 {
     $switch = $Media->get($this->_switch);
     if ($switch && !$Media->has($this->_property)) {
         foreach ($this->_templates as $pattern => $template) {
             if (preg_match($pattern, $switch)) {
                 $Media->set($this->_property, Template::compile($template, $Media->properties(), 'htmlspecialchars'));
                 break;
             }
         }
     }
     return $Media;
 }