Interface Fatal Error - php

So this is my code on my newly created page inside the Entity folder...
use Doctrine\ORM\Mapping as ORM;
use Application\Entity\Categories;
use PerfectWeb\Core\Interfaces\Routable;
use Application\Mapper\Injector;
use PerfectWeb\Core\Traits;
use PerfectWeb\Core\View\Helper\Object;
use PerfectWeb\Core\Utils\Slug;
/**
* #ORM\Entity
*/
class VodCategory extends Categories implements
Entity\Interfaces\Categories, Routable
{
function getRoute($type = Object::ROUTE_TYPE_VIEW)
{
return 'category/categories';
}
function getRouteParams()
{
return
[
Injector::CATEGORY => $this->getID(),
'slug' => Slug::getSlug($this->getSlug()),
];
}
}
And this is my category.php file:
<?php
namespace Application\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use PerfectWeb\Core\Traits;
/**
* Categories
* #ORM\Table(name="categories")
* #ORM\Entity
*/
class Categories
{
use Traits\Entity;
use Traits\User;
use Traits\Name;
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", nullable=false, unique=false)
*/
protected $name;
/**
* #ORM\ManyToOne(targetEntity="Categories", cascade={"persist"})
* #ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
* #var integer
*/
protected $parent = null;
/**
* #var \Application\Entity\User
*
* #ORM\ManyToOne(targetEntity="User", inversedBy="categories")
* #ORM\JoinColumn(name="user", referencedColumnName="id", onDelete="CASCADE")
*/
protected $user;
/**
*
* #ORM\OneToMany(targetEntity="Videos\Entity\Video", mappedBy="category", fetch="EXTRA_LAZY"))
*
*/
protected $videos;
/**
* #var string
*
* #ORM\Column(name="entity", type="string", nullable=true, unique=false)
*/
protected $entity;
/**
*
* construct function for array collection
*/
public function __construct()
{
$this->videos = new ArrayCollection();
}
/**
* #return mixed
*/
public function getVideos()
{
return $this->videos;
}
/**
* #param mixed $videos
*/
public function setVideos($videos)
{
$this->videos = $videos;
}
/**
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Get parent
*
* #return integer
*/
public function getParent()
{
return $this->parent;
}
/**
* Set parent
*
* #param integer $parent
* #return Categories
*/
public function setParent($parent)
{
$this->parent = $parent;
return $this;
}
public function __toString()
{
return $this->getName();
}
}
the first bit of code gives me an error:
Fatal Error Interface 'Categories\Entity\Interfaces\Categories' not found in /var/www/html/camclients/module/Videos/src/Videos/Entity/VodCategory.php
What am I doing wrong?

You implement the interface Entity\Interfaces\Categories inside your category class but this interface cannot be found.
You should have an interface in that namespace (and folder) or you should point to the correct location (the folder/namespace where your interface is located).
If your interface exists then it is probably a namespace issue like #doydoy44 suggested in the comment. Then make sure that the namespace declaration and file location of your interface are correct.

Related

Symfony 2 Entity Repository find() returns empty array

Thank you all for your answers from now. ThatÅ› the question. I have a symfony 2 app with two entities (Tasks and Products). When i tried to find (findBy,findOneBy,findAll) a product it returns an empty array.
Tasks Entity
<?php
namespace pablo\UserBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Task
*
* #ORM\Table(name="tasks")
* #ORM\Entity(repositoryClass="pablo\UserBundle\Repository\TaskRepository")
* #ORM\HasLifecycleCallbacks()
*/
class Task
{
/**
* #ORM\ManyToOne(targetEntity="User", inversedBy="tasks")
* #ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $user;
/**
* #ORM\ManyToOne(targetEntity="Product", inversedBy="task")
* #ORM\JoinColumn(name="product_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $product;
public function __construct()
{
$this->tasks = new ArrayCollection();
}
/**
* Set product
*
* #param \pablo\UserBundle\Entity\Product $product
*
* #return Task
*/
public function setProduct(\pablo\UserBundle\Entity\Product $product = null)
{
$this->product = $product;
return $this;
}
/**
* Get product
*
* #return \pablo\UserBundle\Entity\Product
*/
public function getProduct()
{
return $this->product;
}
/**
* #return ArrayCollection
*/
public function getTasks()
{
return $this->tasks;
}
/**
* #param ArrayCollection $tasks
*/
public function setTasks($tasks)
{
$this->tasks = $tasks;
}
And Products Entity
<?php
namespace pablo\UserBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* Products
*
* #ORM\Table(name="products")
* #ORM\Entity(repositoryClass="pablo\UserBundle\Repository\ProductsRepository")
* #UniqueEntity("productsName")
*/
class Product
{
/**
* #ORM\OneToMany(targetEntity="Task", mappedBy="product")
*/
protected $task;
/**
* #ORM\OneToMany(targetEntity="Publicaciones", mappedBy="product")
*/
protected $publicaciones;
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="products_name", type="string", length=255)
* #Assert\NotBlank()
*/
private $productsName;
public function __construct()
{
$this->task = new ArrayCollection();
}
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set productsName
*
* #param string $productsName
*
* #return Product
*/
public function setProductsName($productsName)
{
$this->productsName = $productsName;
return $this;
}
/**
* Get productsName
*
* #return string
*/
public function getProductsName()
{
return $this->productsName;
}
public function __toString() {
return $this->productsName;
}
/**
* Get task
*
* #return \Doctrine\Common\Collections\ArrayCollection
*/
public function getTask()
{
return $this->task;
}
/**
* Set task
*
* #param \Doctrine\Common\Collections\ArrayCollection $typeSponsor
*
* #return Task
*/
public function setTask($task)
{
$this->task = $task;
}
/**
* #return mixed
*/
public function getPublicaciones()
{
return $this->publicaciones;
}
/**
* #param mixed $publicaciones
*/
public function setPublicaciones($publicaciones)
{
$this->publicaciones = $publicaciones;
}
}
Now, when i tried to find a product from controller it returns an empty array ({}). I can't see what is wrong with this.
$productId = '18';
$product = $this->get('doctrine.orm.default_entity_manager')->getRepository('pabloUserBundle:Product')->find($productId);
Actually you have a result, it just is an empty object because you have not defined which of the properties should be printed.
The best solution is for your entity to implement JsonSerializable.
class Product implements \JsonSerializable
{
...
public function jsonSerialize()
{
return [
"id"=> $this->getId(),
"name" => $this->getProductsName()
];
}
Now it knows what it should print when converting the class to json object.
If you want the task collection also, implement JsonSerializable for the Task Entity and add in Product Entity:
public function jsonSerialize()
{
return [
"id"=> $this->getId(),
"name" => $this->getProductsName(),
"task" => $this->getTask()->toArray()
];
}
The JsonSerializable interface

Symfony 3 / Doctrine many-to-one always returns just last addition- FOSUser/OAuth extended

I am working on a login page, where it should be possible to login with different socialnetwork logins (facebook, twitter, google, etc).
It should work like this: every user has the possibility to add the socialnetwork login that he/she wants, so I want to have it as an One User-> Many Socialnetworklogins relation.
What works: Data is stored in Database, but in the line
var_dump($user->getSocialnetworks());
I just get one Object, not all the ones that should be related to this user. I know that the function justATest adds just a socialnetworklogin to user 1, this was just a test.
<?php
namespace AppBundle\Entity\Registration;
use Doctrine\Common\Collections\ArrayCollection;
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
use HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider as BaseClass;
use Symfony\Component\Security\Core\User\UserInterface;
class FOSUBUserProvider extends BaseClass
{
public function justATest(UserResponseInterface $response)
{
// get user_id and socialnetworkname from response
$userIdInSocialNetwork = $response->getUsername();
$socialnetwork = $response->getResourceOwner()->getName();
$login= new UserInSocialNetworks();
$login->setSocialIdentyfier($response->getEmail());
$login->setSocialNetworkSlug($socialnetwork);
$user = $this->userManager->findUserBy(array(
'id' => 1)
);
$login->setUserId($user);
$user->addSocialNetwork($login);
$this->userManager->updateUser($user);
$users= $this->userManager->findUsers();
var_dump($users);
var_dump($socialnetwork);
var_dump($user->getSocialnetworks());
die();
} }
The User Class:
<?php
/*
* This is the User class, depending on fos_userBundle
*/
namespace AppBundle\Entity\Registration;
use Doctrine\Common\Collections\ArrayCollection as ArrayCollection;
use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Entity
* #ORM\Table(name="user")
*/
class User extends BaseUser
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* #ORM\OneToMany(targetEntity="UserInSocialNetworks", mappedBy="user_id", cascade={"persist", "remove"})
* #var ArrayCollection|null
*/
private $socialnetworks;
/**
* #var string
*
* #ORM\Column(name="family_name",type="string", length=255, nullable=true)
*/
private $familyName;
/**
* #var string
*
* #ORM\Column(name="given_name",type="string", length=255, nullable=true)
*/
private $givenName;
public function __construct()
{
parent::__construct();
$this->socialnetworks = new ArrayCollection();
}
/**
* #return string
*/
public function getFamilyName()
{
return $this->familyName;
}
/**
* #param string $familyName
*/
public function setFamilyName($familyName)
{
$this->familyName = $familyName;
}
/**
* #return string
*/
public function getGivenName()
{
return $this->givenName;
}
/**
* #param string $givenName
*/
public function setGivenName($givenName)
{
$this->givenName = $givenName;
}
/**
* #return ArrayCollection
*/
public function getSocialnetworks()
{
return $this->socialnetworks;
}
/**
* #param Collection UserInSocialNetworks
*/
public function setSocialnetworks($socialnetworks)
{
$this->socialnetworks = $socialnetworks;
}
/**
* #param UserInSocialNetwork
*/
public function addSocialNetwork($socialnetwork)
{
$this->getSocialnetworks()->add($socialnetwork);
}
}
The Class where Socialnetworks for Users are stored:
<?php
namespace AppBundle\Entity\Registration;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* UserInSocialNetworks
*
* #ORM\Table(name="user_in_social_networks")
* #ORM\Entity(repositoryClass="AppBundle\Repository\Registration\UserInSocialNetworksRepository")
*/
class UserInSocialNetworks
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\ManyToOne(targetEntity="User", inversedBy="socialnetworks")
* #ORM\JoinColumn(name="user_id")
* #var User
*
*/
private $userId;
/**
* #var int
*
* #ORM\Column(name="social_network_slug", type="string", length=255, nullable=true)
*/
private $socialNetworkSlug;
/**
* #var string
*
* #ORM\Column(name="social_identifier", type="string", length=255, nullable=true)
*/
private $socialIdentyfier;
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set userId
*
* #param integer $userId
*
* #return UserInSocialNetworks
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId
*
* #return int
*/
public function getUserId()
{
return $this->userId;
}
/**
* #return int
*/
public function getSocialNetworkSlug()
{
return $this->socialNetworkSlug;
}
/**
* #param int $socialNetworkSlug
*/
public function setSocialNetworkSlug($socialNetworkSlug)
{
$this->socialNetworkSlug = $socialNetworkSlug;
}
/**
* #return string
*/
public function getSocialIdentyfier()
{
return $this->socialIdentyfier;
}
/**
* #param string $socialIdentyfier
*/
public function setSocialIdentyfier($socialIdentyfier)
{
$this->socialIdentyfier = $socialIdentyfier;
}
}
This is what I get
object(Doctrine\ORM\PersistentCollection)[545]
private 'snapshot' =>
array (size=1) <------- just one
0 =>
object(AppBundle\Entity\Registration\UserInSocialNetworks)[336]
private 'id' => int 5 <---- I added already 5 line with my code to database
private 'userId' =>
object(AppBundle\Entity\Registration\User)[516]
...
private 'socialNetworkSlug' => string 'google' (length=6)
private 'socialIdentyfier' => string 'blablabla#googlemail.com' (length=24)
sorry, my fault,
the solution was to correct the relations:
class UserInSocialNetworks
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* Many Socialnetwork Logins have one User
* #ORM\ManyToOne(targetEntity="AppBundle\Entity\Registration\User", inversedBy="socialnetworks")
* #ORM\JoinColumn(name="user_id", referencedColumnName="id")
*
*/
private $user;
and
class User extends BaseUser
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* One User can have many social networks
* #ORM\OneToMany(targetEntity="UserInSocialNetworks", mappedBy="user", cascade={"remove"})
*/
private $socialnetworks;

Symfony2 Embedded Forms one to many relationship

I have a doubt w.r.t Embedded Forms. I have a "Properties" entity which has 2 fields "id" and "name" and "Amenities" entity which has 2 fields "id" and "value"(id=1,value=wifi,id=2,value=water,id=3,value=food).I have created these 2 entities,but now I want to save the id of "Properties" and "Amenities" into a separate 3rd table.So, I have created a third entity "Properties_Amenities" and its table "properties_amenities".I have created a "one to many" relationship as shown below.I want to embed "Amenities" into "Properties" with the click of an "Add Amenities" button on the "Properties Form".I am not sure as to where to place the "addAmenities()" and "removeAmenities()" functions in the Entity files. Below are 3 entities:-
Properties.php
<?php
namespace EpitaEvents\FormBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Properties
*
* #ORM\Table(name="properties")
* #ORM\Entity
*/
class Properties
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=100)
*/
private $name;
/**
* #ORM\OneToMany(targetEntity="Properties_Amenities", mappedBy="properties",cascade={"persist"})
**/
private $properties_amenities1;
public function __construct() {
$this->properties_amenities1 = new ArrayCollection();
}
/**
* Get id
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*/
public function getName()
{
return $this->name;
}
/**
* Get properties_amenities1
*/
public function getProperties_Amenities1()
{
return $this->properties_amenities1;
}
/**
* Set properties_amenities1
*
*/
public function setProperties_Amenities1($properties_amenities1)
{
$this->properties_amenities1 = $properties_amenities1;
return $this;
}
/**
* Add Amenities
*
* #return Properties
*/
public function addAmenities(\EpitaEvents\FormBundle\Entity\Properties_Amenities $amenities)
{
$amenities->setProperties($this);
$this->amenities[] = $amenities;
return $this;
}
/**
* Remove Amenities
*
*/
public function removeAmenities(\EpitaEvents\FormBundle\Entity\Properties_Amenities $amenities) {
$this->amenities->removeElement($amenities);
}
}
Amenities.php
<?php
namespace EpitaEvents\FormBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Amenities
*
* #ORM\Table(name="amenities")
* #ORM\Entity
*/
class Amenities
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="value", type="string", length=100)
*/
private $value;
/**
* #ORM\OneToMany(targetEntity="Properties_Amenities", mappedBy="amenities")
**/
private $properties_amenities2;
public function __construct() {
$this->properties_amenities2 = new ArrayCollection();
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set value
*
* #param string $value
* #return Amenities
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Get value
*
* #return string
*/
public function getValue()
{
return $this->value;
}
/**
* Set Properties
*
*/
public function setProperties_Amenities2($properties_amenities2)
{
$this->properties_amenities2 = $properties_amenities2;
return $this;
}
/**
* Get Properties
*
* #return EpitaEvents\FormBundle\Entity\Properties
*/
public function getProperties_Amenities2()
{
return $this->properties_amenities2;
}
}
(Also should the __construct() be put in these 2 above files or in "Properties_Amenities.php"(Below)???)
Properties_Amenities.php
<?php
namespace EpitaEvents\FormBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Properties_Amenities
*
* #ORM\Table(name="properties_amenities")
* #ORM\Entity
*/
class Properties_Amenities
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\ManyToOne(targetEntity="Properties", inversedBy="properties_amenities1")
* #ORM\JoinColumn(name="properties_id", referencedColumnName="id")
**/
private $properties;
/**
* #ORM\ManyToOne(targetEntity="Amenities", inversedBy="properties_amenities2")
* #ORM\JoinColumn(name="amenities_id", referencedColumnName="id")
**/
private $amenities;
function getId() {
return $this->id;
}
function getProperties() {
return $this->properties;
}
function getAmenities() {
return $this->amenities;
}
function setProperties($properties) {
$this->properties = $properties;
}
function setAmenities($amenities) {
$this->amenities = $amenities;
}
}
Can any one suggest as to where to place the "addAmenities()" and "removeAmenities()" functions as I want to save the "id's" of "Properties.php" and "Amenities.php" in a "SEPARATE, THIRD" Entity and table??

ManyToOne relation Symfony2

I have a many to one relation between my entities.
An application can have activities
<?php
namespace AppAcademic\ApplicationBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Activity
*
* #ORM\Table()
* #ORM\Entity
*/
class Activity
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\ManyToOne(targetEntity="AppAcademic\ApplicationBundle\Entity\Application", inversedBy="activity")
* #ORM\JoinColumn(name="application_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $application;
/**
* #var string
*
* #ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
public function setApplication($application)
{
$this->application = $application;
return $this;
}
public function getApplication()
{
return $this->application;
}
/**
* Set title
*
* #param string $title
* #return Activity
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* #return string
*/
public function getTitle()
{
return $this->title;
}
}
And the application
/**
* Application
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="AppAcademic\ApplicationBundle\Entity\ApplicationRepository")
*/
class Application
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\OneToMany(targetEntity="AppAcademic\ApplicationBundle\Entity\Activity", mappedBy="application")
*/
protected $activities;
...
}
I have this in the profiler:
AppAcademic\ApplicationBundle\Entity\Application
The mappings AppAcademic\ApplicationBundle\Entity\Application#activities and AppAcademic\ApplicationBundle\Entity\Activity#application are inconsistent with each other.
AppAcademic\ApplicationBundle\Entity\Application
The mappings AppAcademic\ApplicationBundle\Entity\Application#activities and AppAcademic\ApplicationBundle\Entity\Activity#application are inconsistent with each other.
AppAcademic\ApplicationBundle\Entity\Activity
The association AppAcademic\ApplicationBundle\Entity\Activity#application refers to the inverse side field AppAcademic\ApplicationBundle\Entity\Application#activity which does not exist.
For the mapping annotation ManyToOne on the Activity::$application property, the attribute
inversedBy="activity"
This should be
inversedBy="activities"

Doctrine 2: Update Entity Using Table Schema

I am using doctrine 2 within zend framework 2. To generate methods from existing entities using database table, the console command used is:
php doctrine-module orm:generate-entities --generate-annotations="true" --generate-methods="true" module
I have two namespaces Blog and Location
My question is:
1. When I run above code, only blog entities get updated. I want to know why it is behaving like this?
2. If I want to update only a specific entity, how can i do it?
The blog has two entities: Post and cateogry
Category.php
<?php
namespace Blog\Entity;
use Doctrine\ORM\Mapping as ORM;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Zend\InputFilter\InputFilterAwareInterface;
use Zend\InputFilter\InputFilterInterface;
/**
* Category
*
* #ORM\Table(name="Categories")
* #ORM\Entity
*/
class Category implements InputFilterAwareInterface
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", nullable=false)
*/
private $name;
protected $inputFilter;
/**
* Get Id
*
* #param integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* #param string $name
* #return Category
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
}
Post.php
namespace Blog\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Post
*
* #ORM\Table(name="posts")
* #ORM\Entity
* #ORM\HasLifecycleCallbacks
*/
class Post
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="title", type="string", precision=0, scale=0, nullable=false, unique=false)
*/
private $title;
/**
* #var string
*
* #ORM\Column(name="content", type="text", precision=0, scale=0, nullable=false, unique=false)
*/
private $content;
/**
* #var \DateTime
*
* #ORM\Column(name="created_date", type="datetime", precision=0, scale=0, nullable=false, unique=false)
*/
private $createdDate;
/**
* #var \Blog\Entity\Category
*
* #ORM\ManyToOne(targetEntity="Blog\Entity\Category")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="category_id", referencedColumnName="id", nullable=true)
* })
*/
private $category;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* #param string $title
* #return Post
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* #return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set content
*
* #param string $content
* #return Post
*/
public function setContent($content)
{
$this->content = $content;
return $this;
}
/**
* Get content
*
* #return string
*/
public function getContent()
{
return $this->content;
}
/**
* Set createdDate
*
* #param \DateTime $createdDate
* #return Post
*/
public function setCreatedDate($createdDate)
{
$this->createdDate = $createdDate;
return $this;
}
/**
* Get createdDate
*
* #return \DateTime
*/
public function getCreatedDate()
{
return $this->createdDate;
}
/**
* Set category
*
* #param \Blog\Entity\Category $category
* #return Post
*/
public function setCategory(\Blog\Entity\Category $category = null)
{
$this->category = $category;
return $this;
}
/**
* Get category
*
* #return \Blog\Entity\Category
*/
public function getCategory()
{
return $this->category;
}
}
The Location has Country.php
<?php
namespace Country\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Country
*
* #ORM\Table(name="countries")
* #ORM\Entity
*/
class Country
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=55, nullable=false)
*/
private $name;
}
OF Course everyone need a function on ZF2 that's turns to possible you generate a single entity. but those times you can't do it just by doctrine-orm-module. When you try to run doctrine in Symphony it's acceptable. I'm using doctrine2 with zf2 having the same issue.
I create a PHP Script that I call
Script to Create a Single Entity:
Choose Entity Name.
Generate All Entities on a Temp Folder.
Exclude All non-needed entities from folder.
Copy Single Entity to "src/$module/Entity" Folder.
Is a hack that i got to make it work property as you need.
Use the --filter option to do this.
php doctrine-module orm:generate-entities --filter="Post" ...

Categories