Inheritance: extends bootstrapper\RenderedObject
コード例 #1
0
 /**
  * Statically creates a new MediaObject instance
  *
  * @param  string      $content    Its content
  * @param  string      $media      Its media
  * @param  array       $attributes The media object's attributes
  * @return MediaObject
  */
 public static function create($content, $media = null, $attributes = array())
 {
     static::$object = new static($content);
     if ($media) {
         static::$object->with_image($media);
     }
     if ($attributes) {
         static::$object->attributes = $attributes;
     }
     return static::$object;
 }
コード例 #2
0
 /**
  * Get the body of the contents array
  *
  * @param array $contents
  * @return string
  * @throws MediaObjectException if the body key has not been set
  */
 protected function getBody(array $contents)
 {
     if (!isset($contents['body'])) {
         throw new MediaObjectException('You must pass in the body to each object');
     }
     $string = $contents['body'];
     if (isset($contents['nest'])) {
         $object = new MediaObject();
         $string .= $object->withContents($contents['nest']);
     }
     return $string;
 }
コード例 #3
0
ファイル: _ide_helper.php プロジェクト: qarlson/infr
 /**
  * Adds the given classes to attributes
  *
  * @param array $classes
  * @return $this 
  * @static 
  */
 public static function addClass($classes)
 {
     //Method inherited from \Bootstrapper\RenderedObject
     return \Bootstrapper\MediaObject::addClass($classes);
 }
コード例 #4
0
    public function testNesting()
    {

        $media = MediaObject::create('foo', 'bar', $this->testAttributes)
            ->nest(MediaObject::create('foo2', 'bar2')->with_h1('foobar'))
            ->__toString();
        $matcher =
            '<div class="foo media" data-foo="bar">' .
            '<a class="pull-left"><img src="http://test/bar" class="media-object" alt="bar"></a>' .
            '<div class="media-body">foo' .
            '<div class="media">' .
            '<a class="pull-left"><img src="http://test/bar2" class="media-object" alt="bar2"></a>' .
            '<div class="media-body"><h1 class="media-heading">foobar</h1>foo2</div>' .
            '</div>' .
            '</div>' .
            '</div>';

        $this->assertEquals($matcher, $media);
    }