Permalink
Browse files

Beta4 readiness

- Updated Module class to comply with latest changes to ModuleManager
- Updated configuration to work with ServiceManager
- Updated code to work with new Interface declarations
- Updated code to be EventsCapable and EventManagerAware
- Updated code to use new InputFilter component
  • Loading branch information...
weierophinney committed May 29, 2012
1 parent b6dc217 commit c671b4c82afa8d1c55bf7e1eb1bc4055c8aa0f4a
View
@@ -2,12 +2,10 @@
namespace PhlyBlog;
-use Traversable,
- Zend\EventManager\StaticEventManager,
- Zend\Module\Consumer\AutoloaderProvider,
- Zend\Stdlib\ArrayUtils;
+use Traversable;
+use Zend\Stdlib\ArrayUtils;
-class Module implements AutoloaderProvider
+class Module
{
public static $config;
@@ -25,23 +23,19 @@ public function getConfig()
return include __DIR__ . '/config/module.config.php';
}
- public function init($manager)
- {
- $events = StaticEventManager::getInstance();
- $events->attach('bootstrap', 'bootstrap', array($this, 'onBootstrap'));
- }
-
public function onBootstrap($e)
{
- self::$config = $e->getParam('config');
+ $app = $e->getApplication();
+ $services = $app->getServiceManager();
+ self::$config = $services->get('config');
if (self::$config instanceof Traversable) {
self::$config = ArrayUtils::iteratorToArray(self::$config);
}
}
- public static function prepareCompilerView($view, $config, $locator)
+ public static function prepareCompilerView($view, $config, $services)
{
- $renderer = $locator->get('Zend\View\Renderer\PhpRenderer');
+ $renderer = $services->get('ViewRenderer');
$view->addRenderingStrategy(function($e) use ($renderer) {
return $renderer;
}, 100);
View
@@ -81,8 +81,8 @@
// Get locator, and grab renderer and view from it
$config = Module::$config;
-$locator = $application->getLocator();
-$view = $locator->get('Zend\View\View');
+$locator = $application->getServiceManager();
+$view = $locator->get('View');
$view->events()->clearListeners('renderer');
$view->events()->clearListeners('response');
View
@@ -1,62 +1,55 @@
<?php
-$config = array();
-
-$config['blog'] = array(
- 'options' => array(
- 'author_feed_filename_template' => 'public/blog/author/%s-%s.xml',
- 'author_feed_title_template' => 'Author: %s',
- 'by_author_filename_template' => 'public/blog/author/%s-p%d.html',
- 'by_day_filename_template' => 'public/blog/day/%s-p%d.html',
- 'by_month_filename_template' => 'public/blog/month/%s-p%d.html',
- 'by_tag_filename_template' => 'public/blog/tag/%s-p%d.html',
- 'by_year_filename_template' => 'public/blog/year/%s-p%d.html',
- 'entries_filename_template' => 'public/blog-p%d.html',
- 'entries_template' => 'phly-blog/list',
- 'entry_filename_template' => 'public/blog/%s.html',
- 'entry_link_template' => '/blog/%s.html',
- 'entry_template' => 'phly-blog/entry',
- 'feed_author_email' => 'you@your.tld',
- 'feed_author_name' => "Your name here",
- 'feed_author_uri' => 'http://your.tld',
- 'feed_filename' => 'public/blog-%s.xml',
- 'feed_hostname' => 'http://your.tld',
- 'feed_title' => 'Blog Entries',
- 'tag_feed_filename_template' => 'public/blog/tag/%s-%s.xml',
- 'tag_feed_title_template' => 'Tag: %s',
- 'tag_cloud_options' => array('tagDecorator' => array(
- 'decorator' => 'html_tag',
- 'options' => array(
- 'fontSizeUnit' => '%',
- 'minFontSize' => 80,
- 'maxFontSize' => 300,
- ),
- )),
+return array(
+ 'blog' => array(
+ 'options' => array(
+ 'author_feed_filename_template' => 'public/blog/author/%s-%s.xml',
+ 'author_feed_title_template' => 'Author: %s',
+ 'by_author_filename_template' => 'public/blog/author/%s-p%d.html',
+ 'by_day_filename_template' => 'public/blog/day/%s-p%d.html',
+ 'by_month_filename_template' => 'public/blog/month/%s-p%d.html',
+ 'by_tag_filename_template' => 'public/blog/tag/%s-p%d.html',
+ 'by_year_filename_template' => 'public/blog/year/%s-p%d.html',
+ 'entries_filename_template' => 'public/blog-p%d.html',
+ 'entries_template' => 'phly-blog/list',
+ 'entry_filename_template' => 'public/blog/%s.html',
+ 'entry_link_template' => '/blog/%s.html',
+ 'entry_template' => 'phly-blog/entry',
+ 'feed_author_email' => 'you@your.tld',
+ 'feed_author_name' => "Your name here",
+ 'feed_author_uri' => 'http://your.tld',
+ 'feed_filename' => 'public/blog-%s.xml',
+ 'feed_hostname' => 'http://your.tld',
+ 'feed_title' => 'Blog Entries',
+ 'tag_feed_filename_template' => 'public/blog/tag/%s-%s.xml',
+ 'tag_feed_title_template' => 'Tag: %s',
+ 'tag_cloud_options' => array('tagDecorator' => array(
+ 'decorator' => 'html_tag',
+ 'options' => array(
+ 'fontSizeUnit' => '%',
+ 'minFontSize' => 80,
+ 'maxFontSize' => 300,
+ ),
+ )),
+ ),
+ 'posts_path' => 'data/blog/',
+ 'view_callback' => array('PhlyBlog\Module', 'prepareCompilerView'),
+ 'cloud_callback' => false,
),
- 'posts_path' => 'data/blog/',
- 'view_callback' => array('PhlyBlog\Module', 'prepareCompilerView'),
- 'cloud_callback' => false,
-);
-$config['di'] = array(
-'instance' => array(
- 'Zend\View\Resolver\TemplateMapResolver' => array('parameters' => array(
- 'map' => array(
+ 'view_manager' => array(
+ 'template_map' => array(
'phly-blog/entry-short' => __DIR__ . '/../view/phly-blog/entry-short.phtml',
'phly-blog/entry' => __DIR__ . '/../view/phly-blog/entry.phtml',
'phly-blog/list' => __DIR__ . '/../view/phly-blog/list.phtml',
'phly-blog/paginator' => __DIR__ . '/../view/phly-blog/paginator.phtml',
'phly-blog/tags' => __DIR__ . '/../view/phly-blog/tags.phtml',
),
- )),
-
- 'Zend\View\Resolver\TemplatePathStack' => array('parameters' => array(
- 'paths' => array(
+ 'template_path_stack' => array(
'phly-blog' => __DIR__ . '/../view',
),
- )),
-
- /* Routes are only included to simplify url creation */
- 'Zend\Mvc\Router\RouteStackInterface' => array('parameters' => array(
+ ),
+
+ 'router' => array(
'routes' => array(
'phly-blog' => array(
'type' => 'Literal',
@@ -194,7 +187,5 @@
),
),
),
- )),
-));
-
-return $config;
+ ),
+);
@@ -2,7 +2,7 @@
namespace PhlyBlog;
use PhlyCommon\Entity as EntityDefinition,
- Zend\Filter\InputFilter;
+ Zend\InputFilter\InputFilterInterface;
class AuthorEntity implements EntityDefinition
{
@@ -105,7 +105,7 @@ public function getUrl()
return $this->url;
}
- public function setInputFilter(InputFilter $filter)
+ public function setInputFilter(InputFilterInterface $filter)
{
$this->filter = $filter;
return $this;
@@ -128,7 +128,7 @@ public function isValid()
// If valid, push the filtered values back into the object
if ($valid) {
- $this->fromArray($filter->getEscaped());
+ $this->fromArray($filter->getValues());
}
// Return validation result
View
@@ -3,10 +3,14 @@
use DateTime;
use DateTimezone;
-use Zend\EventManager\EventCollection;
+use Zend\EventManager\EventManagerAwareInterface;
+use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\EventManager;
+use Zend\EventManager\EventsCapableInterface;
-class Compiler
+class Compiler implements
+ EventManagerAwareInterface,
+ EventsCapableInterface
{
protected $events;
protected $files;
@@ -16,7 +20,7 @@ public function __construct(Compiler\PhpFileFilter $files)
$this->files = $files;
}
- public function setEventManager(EventCollection $events)
+ public function setEventManager(EventManagerInterface $events)
{
$events->setIdentifiers(array(
__CLASS__,
@@ -6,15 +6,15 @@
use PhlyBlog\Compiler\Event;
use PhlyBlog\Compiler\ResponseFile;
use PhlyBlog\Compiler\WriterInterface;
-use Zend\EventManager\EventCollection as Events;
-use Zend\EventManager\ListenerAggregate;
+use Zend\EventManager\EventManagerInterface as Events;
+use Zend\EventManager\ListenerAggregateInterface;
use Zend\Feed\Writer\Feed as FeedWriter;
use Zend\Paginator\Adapter\ArrayAdapter as ArrayPaginator;
use Zend\Paginator\Paginator;
use Zend\View\Model\ViewModel;
use Zend\View\View;
-abstract class AbstractList implements ListenerAggregate, ListenerInterface
+abstract class AbstractList implements ListenerAggregateInterface, ListenerInterface
{
protected $listeners = array();
protected $options;
@@ -5,12 +5,12 @@
use PhlyBlog\CompilerOptions;
use PhlyBlog\Compiler\Event;
use PhlyBlog\Compiler\ResponseFile;
-use Zend\EventManager\EventCollection as Events;
-use Zend\EventManager\ListenerAggregate;
+use Zend\EventManager\EventManagerInterface as Events;
+use Zend\EventManager\ListenerAggregateInterface;
use Zend\View\View;
use Zend\View\Model\ViewModel;
-class Entries implements ListenerAggregate
+class Entries implements ListenerAggregateInterface
{
protected $entries;
protected $listeners = array();
@@ -3,7 +3,7 @@
use PhlyCommon\Entity as EntityDefinition,
PhlyCommon\Filter\Timestamp as TimestampFilter,
- Zend\Filter\InputFilter;
+ Zend\InputFilter\InputFilterInterface;
class EntryEntity implements EntityDefinition
{
@@ -576,7 +576,7 @@ public function fromArray(array $array)
return $this;
}
- public function setInputFilter(InputFilter $filter)
+ public function setInputFilter(InputFilterInterface $filter)
{
$this->filter = $filter;
return $this;
@@ -599,7 +599,7 @@ public function isValid()
// If valid, push the filtered values back into the object
if ($valid) {
- $this->fromArray($filter->getEscaped());
+ $this->fromArray($filter->getValues());
}
// Return validation result
@@ -1,30 +1,60 @@
<?php
namespace PhlyBlog\Filter;
-use Zend\Filter\InputFilter;
+use Zend\InputFilter\InputFilter;
class AuthorFilter extends InputFilter
{
public function __construct()
{
- $filterRules = array(
- 'id' => 'string_trim',
- 'name' => array('string_trim', 'strip_tags'),
- 'email' => 'string_trim',
- 'url' => 'string_trim',
- );
+ $this->add(array(
+ 'name' => 'id',
+ 'filters' => array(
+ array('name' => 'string_trim'),
+ ),
+ 'validators' => array(
+ new AuthorIsValid(),
+ ),
+ 'required' => true,
+ ));
- $validatorRules = array(
- 'id' => array(new AuthorIsValid(), 'message' => 'Missing identifier (short name).'),
- 'name' => array(array('string_length', 1), 'message' => 'Name must be at least 1 characters in length, and non-empty.', 'required' => true),
- 'email' => array('emailaddress', 'message' => 'Invalid email address provided', 'allowEmpty' => true),
- 'url' => array(new Url(), 'message' => 'Invalid url provided', 'allowEmpty' => true),
- );
+ $this->add(array(
+ 'name' => 'name',
+ 'filters' => array(
+ array('name' => 'string_trim'),
+ array('name' => 'strip_tags'),
+ ),
+ 'validators' => array(
+ array(
+ 'name' => 'string_length',
+ 'options' => array(
+ 'min' => 1,
+ ),
+ ),
+ ),
+ 'required' => true,
+ ));
- $options = array(
- 'escapeFilter' => 'string_trim',
- );
+ $this->add(array(
+ 'name' => 'email',
+ 'filters' => array(
+ array('name' => 'string_trim'),
+ ),
+ 'validators' => array(
+ array('name' => 'emailaddress'),
+ ),
+ 'allow_empty' => true,
+ ));
- parent::__construct($filterRules, $validatorRules, null, $options);
+ $this->add(array(
+ 'name' => 'url',
+ 'filters' => array(
+ array('name' => 'string_trim'),
+ ),
+ 'validators' => array(
+ new Url(),
+ ),
+ 'allow_empty' => true,
+ ));
}
}
Oops, something went wrong.

0 comments on commit c671b4c

Please sign in to comment.