Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit 6bc5f8a

Browse files
Import classes and use their shortname instead of the FQCN
1 parent 053e946 commit 6bc5f8a

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

doc/book/quick-start.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -534,24 +534,26 @@ priority. Typically, you will register this during the bootstrap event.
534534
```php
535535
namespace Content;
536536

537+
use Zend\Mvc\MvcEvent;
538+
537539
class Module
538540
{
539541
/**
540-
* @param \Zend\Mvc\MvcEvent $e The MvcEvent instance
542+
* @param MvcEvent $e The MvcEvent instance
541543
* @return void
542544
*/
543-
public function onBootstrap($e)
545+
public function onBootstrap(MvcEvent $e)
544546
{
545547
// Register a dispatch event
546548
$app = $e->getParam('application');
547549
$app->getEventManager()->attach('dispatch', [$this, 'setLayout']);
548550
}
549551

550552
/**
551-
* @param \Zend\Mvc\MvcEvent $e The MvcEvent instance
553+
* @param MvcEvent $e The MvcEvent instance
552554
* @return void
553555
*/
554-
public function setLayout($e)
556+
public function setLayout(MvcEvent $e)
555557
{
556558
$matches = $e->getRouteMatch();
557559
$controller = $matches->getParam('controller');
@@ -602,13 +604,15 @@ register the `JsonStrategy`:
602604
```php
603605
namespace Application;
604606

607+
use Zend\Mvc\MvcEvent;
608+
605609
class Module
606610
{
607611
/**
608-
* @param \Zend\Mvc\MvcEvent $e The MvcEvent instance
612+
* @param MvcEvent $e The MvcEvent instance
609613
* @return void
610614
*/
611-
public function onBootstrap($e)
615+
public function onBootstrap(MvcEvent $e)
612616
{
613617
// Register a "render" event, at high priority (so it executes prior
614618
// to the view attempting to render)
@@ -617,10 +621,10 @@ class Module
617621
}
618622

619623
/**
620-
* @param \Zend\Mvc\MvcEvent $e The MvcEvent instance
624+
* @param MvcEvent $e The MvcEvent instance
621625
* @return void
622626
*/
623-
public function registerJsonStrategy($e)
627+
public function registerJsonStrategy(MvcEvent $e)
624628
{
625629
$app = $e->getTarget();
626630
$locator = $app->getServiceManager();
@@ -641,7 +645,9 @@ You could also use the module configuration to add the strategies:
641645
```php
642646
namespace Application;
643647

644-
class Module implements \Zend\ModuleManager\Feature\ConfigProviderInterface
648+
use Zend\ModuleManager\Feature\ConfigProviderInterface;
649+
650+
class Module implements ConfigProviderInterface
645651
{
646652
/**
647653
* Returns configuration to merge with application configuration
@@ -671,24 +677,26 @@ the layout for a specific module:
671677
```php
672678
namespace Application;
673679

680+
use Zend\Mvc\MvcEvent;
681+
674682
class Module
675683
{
676684
/**
677-
* @param \Zend\Mvc\MvcEvent $e The MvcEvent instance
685+
* @param MvcEvent $e The MvcEvent instance
678686
* @return void
679687
*/
680-
public function onBootstrap($e)
688+
public function onBootstrap(MvcEvent $e)
681689
{
682690
// Register a render event
683691
$app = $e->getParam('application');
684692
$app->getEventManager()->attach('render', [$this, 'registerJsonStrategy'], 100);
685693
}
686694

687695
/**
688-
* @param \Zend\Mvc\MvcEvent $e The MvcEvent instance
696+
* @param MvcEvent $e The MvcEvent instance
689697
* @return void
690698
*/
691-
public function registerJsonStrategy($e)
699+
public function registerJsonStrategy(MvcEvent $e)
692700
{
693701
$matches = $e->getRouteMatch();
694702
$controller = $matches->getParam('controller');
@@ -720,15 +728,20 @@ If you successfully registered the Strategy you need to use the appropriate `Vie
720728
```php
721729
namespace Application;
722730

723-
class MyController extends \Zend\Mvc\Controller\AbstractActionController
731+
use Zend\Mvc\Controller\AbstractActionController;
732+
use Zend\View\Model\ViewModel;
733+
use Zend\View\Model\JsonModel;
734+
use Zend\View\Model\FeedModel;
735+
736+
class MyController extends AbstractActionController
724737
{
725738
/**
726739
* Lists the items as HTML
727740
*/
728741
public function listAction()
729742
{
730743
$items = /* ... get items ... */;
731-
$viewModel = new \Zend\View\Model\ViewModel();
744+
$viewModel = new ViewModel();
732745
$viewModel->setVariable('items', $items);
733746
return $viewModel;
734747
}
@@ -739,7 +752,7 @@ class MyController extends \Zend\Mvc\Controller\AbstractActionController
739752
public function listJsonAction()
740753
{
741754
$items = /* ... get items ... */;
742-
$viewModel = new \Zend\View\Model\JsonModel();
755+
$viewModel = new JsonModel();
743756
$viewModel->setVariable('items', $items);
744757
return $viewModel;
745758
}
@@ -750,7 +763,7 @@ class MyController extends \Zend\Mvc\Controller\AbstractActionController
750763
public function listFeedAction()
751764
{
752765
$items = /* ... get items ... */;
753-
$viewModel = new \Zend\View\Model\FeedModel();
766+
$viewModel = new FeedModel();
754767
$viewModel->setVariable('items', $items);
755768
return $viewModel;
756769
}

0 commit comments

Comments
 (0)