/**
* Configuration of the input filter for element based on the provided specification.
* Specification can contain any of the following:
*
* .-------------------.----------------.-----------------.-----------------.--------------------.
* | continue_if_empty | required | allow_empty | Is empty valid? | Apply other filter |
* |-------------------+----------------+-----------------+-----------------+--------------------|
* | false (default) | true (default) | false (default) | false | Not |
* | false (default) | true (default) | true | true | Not |
* | false (default) | false | false (default) | true | Not |
* | true | true (default) | false (default) | true | Yes |
* |-------------------+----------------+-----------------+-----------------+--------------------|
* | false (default) | false | true | true | Not |
* | true | true (default) | true | true | Yes |
* | true | false | false (default) | true | Yes |
* | true | false | true | true | Yes |
* '-------------------'----------------'-----------------'-----------------'--------------------'
*/
<?php
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
return false;
}
// Setup autoloading
require 'init_autoloader.php';
// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
<?php
use Zend\Mvc\Application;
use Zend\Stdlib\ArrayUtils;
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server') {
$path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
if (__FILE__ !== $path && is_file($path)) {
return false;
}
unset($path);
}
// Composer autoloading
include __DIR__ . '/../vendor/autoload.php';
if (! class_exists(Application::class)) {
throw new RuntimeException(
"Unable to load application.\n"
. "- Type `composer install` if you are developing locally.\n"
. "- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\n"
. "- Type `docker-compose run zf composer install` if you are using Docker.\n"
);
}
// Retrieve configuration
$appConfig = require __DIR__ . '/../config/application.config.php';
if (file_exists(__DIR__ . '/../config/development.config.php')) {
$appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');
}
// Run the application!
Application::init($appConfig)->run();
<?php
return [
'doctrine' => [
'connection' => [
'orm_default' => [
'driverClass' => \Doctrine\DBAL\Driver\PDOMySql\Driver::class,
'params' => [
'host' => 'localhost',
'port' => '3306',
'user' => 'username',
'password' => 'password',
'dbname' => 'database',
'driverOptions' => [
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'',
],
],
],
],
],
];
return (new ViewModel())
->setVariables($productsView->getItemsVariables())
;
It is not possible to use join columns pointing to non-primary keys. Doctrine will think these are the primary keys and create lazy-loading proxies with the data, which can lead to unexpected results. Doctrine can for performance reasons not validate the correctness of this settings at runtime but only through the Validate Schema command.
'router' => [
'routes' => [
/** Configuration of the 'shop' routes. */
'shop' => [
'type' => 'Literal',
'options' => [
'route' => '/shop/',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
/** Configuration of the 'shop/category' routes. */
'category' => [
'type' => 'Literal',
'options' => [
'route' => 'category/',
'defaults' => [
'controller' => Controller\CategoryController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
/** Configuration of the 'shop/category/action' routes. */
'action' => [
'type' => 'Segment',
'options' => [
'route' => '[:action]',
'constraints' => [
'action' => '(create)',
],
],
],
/** Configuration of the 'shop/category/category' routes. */
'category' => [
'type' => 'Segment',
'options' => [
'route' => '[:id/]',
'constraints' => [
'id' => '[0-9]+',
],
'defaults' => [
'id' => null,
],
],
'may_terminate' => true,
'child_routes' => [
/** Configuration of the 'shop/category/category/action' routes. */
'action' => [
'type' => 'Segment',
'options' => [
'route' => '[:action]',
'constraints' => [
'action' => '(update|delete)',
],
],
],
],
],
],
],
],
],
],
],
.---------------------------------------------------------------------------------------.
| Property | Type | Description |
|---------------------------------------------------------------------------------------|
| first | integer | First page number (typically 1). |
| firstItemNumber | integer | Absolute number of the first item on this page. |
| firstPageInRange | integer | First page in the range returned by the scrolling style. |
| current | integer | Current page number. |
| currentItemCount | integer | Number of items on this page. |
| itemCountPerPage | integer | Maximum number of items available to each page. |
| last | integer | Last page number. |
| lastItemNumber | integer | Absolute number of the last item on this page. |
| lastPageInRange | integer | Last page in the range returned by the scrolling style. |
| next | integer | Next page number. |
| pageCount | integer | Number of pages. |
| pagesInRange | array | Array of pages returned by the scrolling style. |
| previous | integer | Previous page number. |
| totalItemCount | integer | Total number of items. |
'---------------------------------------------------------------------------------------'
<?php
/**
* Auto generated by MySQL Workbench Schema Exporter.
* Version 3.0.2 (doctrine2-annotation) on 2016-07-26 19:31:50.
* Goto https://github.com/johmue/mysql-workbench-schema-exporter for more
* information.
*/
namespace TestModule\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* TestModule\Entity\Portfolio
*
* @ORM\Entity()
* @ORM\Table(name="Portfolio")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"base":"BasePortfolio", "extended":"Portfolio"})
*/
class BasePortfolio
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
*/
protected $idPortfolio;
/**
* @ORM\ManyToMany(targetEntity="Tag", mappedBy="portfolios")
*/
protected $tags;
public function __construct()
{
$this->tags = new ArrayCollection();
}
/**
* Set the value of idPortfolio.
*
* @param integer $idPortfolio
* @return \TestModule\Entity\Portfolio
*/
public function setIdPortfolio($idPortfolio)
{
$this->idPortfolio = $idPortfolio;
return $this;
}
/**
* Get the value of idPortfolio.
*
* @return integer
*/
public function getIdPortfolio()
{
return $this->idPortfolio;
}
/**
* Add Tag entity to collection.
*
* @param \TestModule\Entity\Tag $tag
* @return \TestModule\Entity\Portfolio
*/
public function addTag(Tag $tag)
{
$this->tags[] = $tag;
return $this;
}
/**
* Remove Tag entity from collection.
*
* @param \TestModule\Entity\Tag $tag
* @return \TestModule\Entity\Portfolio
*/
public function removeTag(Tag $tag)
{
$this->tags->removeElement($tag);
return $this;
}
/**
* Get Tag entity collection.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getTags()
{
return $this->tags;
}
}
<?php
/**
* Auto generated by MySQL Workbench Schema Exporter.
* Version 3.0.2 (doctrine2-annotation) on 2016-07-26 19:31:50.
* Goto https://github.com/johmue/mysql-workbench-schema-exporter for more
* information.
*/
namespace TestModule\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* TestModule\Entity\Tag
*
* @ORM\Entity()
* @ORM\Table(name="Tag")
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"base":"BaseTag", "extended":"Tag"})
*/
class BaseTag
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
*/
protected $idTag;
/**
* @ORM\ManyToMany(targetEntity="Portfolio", inversedBy="tags")
* @ORM\JoinTable(name="Portfolio_has_Tag",
* joinColumns={@ORM\JoinColumn(name="Tag_idTag", referencedColumnName="idTag", nullable=false)},
* inverseJoinColumns={@ORM\JoinColumn(name="Portfolio_idPortfolio", referencedColumnName="idPortfolio", nullable=false)}
* )
*/
protected $portfolios;
public function __construct()
{
$this->portfolios = new ArrayCollection();
}
/**
* Set the value of idTag.
*
* @param integer $idTag
* @return \TestModule\Entity\Tag
*/
public function setIdTag($idTag)
{
$this->idTag = $idTag;
return $this;
}
/**
* Get the value of idTag.
*
* @return integer
*/
public function getIdTag()
{
return $this->idTag;
}
/**
* Add Portfolio entity to collection.
*
* @param \TestModule\Entity\Portfolio $portfolio
* @return \TestModule\Entity\Tag
*/
public function addPortfolio(Portfolio $portfolio)
{
$portfolio->addTag($this);
$this->portfolios[] = $portfolio;
return $this;
}
/**
* Remove Portfolio entity from collection.
*
* @param \TestModule\Entity\Portfolio $portfolio
* @return \TestModule\Entity\Tag
*/
public function removePortfolio(Portfolio $portfolio)
{
$portfolio->removeTag($this);
$this->portfolios->removeElement($portfolio);
return $this;
}
/**
* Get Portfolio entity collection.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPortfolios()
{
return $this->portfolios;
}
}