Carew\Event\Listener\Metadata\Optimization::onDocument PHP Method

onDocument() public method

public onDocument ( CarewEvent $event )
$event Carew\Event\CarewEvent
    public function onDocument(CarewEvent $event)
    {
        $document = $event->getSubject();
        if (Document::TYPE_POST == $document->getType()) {
            $this->onPost($document);
        } elseif (Document::TYPE_API == $document->getType()) {
            $this->onApi($document);
        }
    }

Usage Example

Beispiel #1
0
 /**
  * @dataProvider getOnPostTests
  */
 public function testOnPost($expected, $format)
 {
     $file = $this->prophesize('Symfony\\Component\\Finder\\SplFileInfo');
     $file->getBasename('.md')->willReturn('2010-09-09-foobar-bar');
     $file->__toString()->willReturn('');
     $document = new Document($file->reveal(), null, Document::TYPE_POST);
     $event = new CarewEvent($document);
     $extraction = new Optimization($format);
     $extraction->onDocument($event);
     $this->assertSame($expected, $document->getPath());
 }