Zend Framework, Doctrine 2 #ManyToOne - zend-framework

I basicky followed this http://www.zendcasts.com/one-to-many-with-doctrine-2/2011/03/ tutorial to the step (source codes can be downloaded from there). And everything works just fine, so I got 2 Entities - Purchase and User. If I query User everything is fine, but if I query Purchase, like so:
$entityManager->createQuery('select p from ZC\Entity\Purchase p where p.id = 1')->execute();
I will get an Fatal error:
Fatal error: require() [function.require]: Failed opening required 'C:\xampp\htdocs\CoChces\application/../library/CC/Entity/Proxy\CCEntityCategoryProxy.php' (include_path='C:\xampp\htdocs\CoChces\application/../library;C:\xampp\htdocs\CoChces\library;.;C:\xampp\php\PEAR') in C:\xampp\htdocs\CoChces\library\Doctrine\ORM\Proxy\ProxyFactory.php on line 85
But if i comment this lines in Purchase:
/**
*
* #var User
* #ManyToOne(targetEntity="User")
* #JoinColumns({
* #JoinColumn(name="user_id", referencedColumnName="id")
* })
*/
private $user;
Everithing works just fine. So there must be some kind of problem with #ManyToOne annotation. Anyone know what to do with it? Perhaps some workaround?
Thanks a lot for answers..
I'm using PHP 5.3.8

Couple of things...
Your annotation syntax doesn't appear to be correct. Try
/**
* #var User
* #ManyToOne(targetEntity="User")
*/
private $user;
#JoinColumns doesn't appear anywhere in the documentation. Also, the #JoinColumn annotation is redundant as you are using the default values. See http://www.doctrine-project.org/docs/orm/2.1/en/reference/association-mapping.html#many-to-one-unidirectional
Your DQL query references the ZC namespace root but the error message says CC. Which is correct?

Related

TYPO3 Frontend User Repository

I've got some problems upgrading my extension from TYPO3 6.2 to 7.6.X
got this code
/**
* Protected Variable FrontendUserRepository wird mit NULL initialisiert.
*
* #var \Typo3\CMS\Extbase\Domain\Repository\FrontendUserRepository
* #inject
*/
protected $FrontendUserRepository = NULL;
and got this error:
You have to spell the namespace correctly. In this case TYPO3 has to be in upper case:
\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
The class should be loaded. No further actions required but flushing the system cache.
Btw: "TYPO3" is always the correct spelling :)

Repository doesn't generate in Doctrine 2

I'm working with Zend Framework 2 and Doctrine 2 and my application has two modules:
Privado (Private)
Publico (Public).
I created an Entity in Public, my first entity in public, and now I'm trying to create her repository using the command:
./vendor/bin/doctrine-module orm:generate-repositories ./module/Publico/src/
And all the repositories from Private module are created but the repository from my new entity in Public module is not created.
So, what happened? What am I doing wrong?
I have found the problem, I have been make a terrible mistake. I don't define correctly the Repository class.
Wrong:
/** #ORM\Entity
* #ORM\Table(name="menu")
* #ORM\Entity(repositoryClass="Privado\Repository\EstadoRepository")
*/
Right:
/** #ORM\Entity
* #ORM\Table(name="menu")
* #ORM\Entity(repositoryClass="Publico\Repository\MenuRepository")
*/

Netbeans 8 auto add author to method comment

When I type a methods and generate comments via /** enter.
It generates comment like this.
/**
* #param int $weight
* #return \KT_Forbes_Theme_Model
*/
Is the a possibility to auto add #author ?
/**
* #author A good guy
* #param int $weight
* #return \KT_Forbes_Theme_Model
*/
I have to add the #autor manualy for all the method, it is really anoing.
It seems that it is not possible in current NetBeans versions as reported in https://netbeans.org/bugzilla/show_bug.cgi?id=251426. Also there are some related posts about this issue Modify command / template for function commenting in NetBeans. Triggering with "/** + Enter key" or Edit Comment Template in Netbeans PHP 6.8 (this last one does not solve the issue - at least in NetBeans 8.1).
I'm currently fighting with the IDE to include the auto comments with some data cause the comment added looks like:
/**
*
*/
whitout any info included.
This output is given typically for void methods, with no parameters.
i.e. public void parameterMapping()
For methods that have parameters and a return value should look like this:
/**
*
* #param parameter
* #return
*/
private ASTNode recursiveParameterParser(ASTNode parameter)

Get List of TYPO3 FE_User Group

How can I get a list with all my frontenduser groups?
I've tried this:
/**
* feUserGroupRepository
*
* #var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository
* #inject
*/
protected $feUserGroupRepository = NULL;`
and then this:
$usergroups = $this->feUserGroupRepository->findAll();
I got this error: Call to a member function findAll() on a non-object
And I tried this way:
/**
* #var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository $feUserGroupRepository
*/
$feUserGroupRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserGroupRepository');
$allUsers = $feUserGroupRepository->findAll();`
dosn't work at all i've got this error message
PHP Catchable fatal error: Argument 1 passed to
TYPO3\CMS\Extbase\Persistence\Repository::__construct() must implement interface
TYPO3\CMS\Extbase\Object\ObjectManagerInterface, none given, called in
C:\xampp\htdocs\typo3\typo3\sysext\core\Classes\Utility\GeneralUtility.php on
line 4431 and
defined in C:\xampp\htdocs\typo3\typo3\sysext\extbase\Classes\Persistence\Repository.php
How can I get a list with all feusergroups?
Rcord Type?
The error indicates that the Dependency Injection didn't work. Please make sure that you flush the System Cache after doing changes that are cached in the Database, which is the case for changes of class names or changes that require dependencies to be rebuilt.
You can flush the system cache in the Install Tool ("Important actions") or directly in the Backend if you are running TYPO3 in Development context. "Flush general caches" does not (!) flush the database-based system caches.
Depending on the TYPO3 version you're running, you will need to set the Record Type of your Frontend Usergroups (column "tx_extbase_type") to FrontendUserGroup.
Using makeInstance for generating an instance of a Repository is discouraged. You should use dependency injection where possible (in this case it is), or, where not possible, the ObjectManager.

Generate getters and setters (Zend Studio for Eclipse)

I'm using Zend Studio for Eclipse (Linux), and I'm trying to generate getter and setters methods in a PHP class.
I try to do this: http://files.zend.com/help/Zend-Studio-Eclipse-Help/creating_getters_and_setters.htm
but I haven't "Generate Getters and Setters" option in Source Menu, it's missed!
Could u help me? Thanks!
Like Omnipotent say, you can use templates to do this. Here what I use:
/**
* #var ${PropertyType}
*/
private $$m${PropertyName};
${cursor}
/**
* Getter for ${PropertyName}
*
* #author ${user}
* #since ${date} ${time}
* #return ${PropertyType} private variable $$m_${PropertyName}
*/
public function get${PropertyName}()
{
return $$this->m_${PropertyName};
}
/**
* Setter for ${PropertyName}
*
* #author ${user}
* #since ${date} ${time}
* #param ${PropertyType} $$Value
*/
public function set${PropertyName}($$Value)
{
$$this->m_${PropertyName} = $$Value;
}
To create the template just go to the preferences. Then in PHP/Templates you will have your list of templates.
It has to be there under the menu - source in Eclipse. Could you provide a snapshot of your Eclipse to verify.
EDITED: I guess it is not possible to generate getters and setters automatically in your version, though you would be able to create templates for the same and use it as per your requirements. Omnipotent (0 seconds ago)
I haven't seen anyone mention the Zend Studio ctrl+3 shortcut/search:
ctrl+3 and search...
I type "setters", and first option on the menu is the "Generate Getters and Setters" wizard.
If there is a 'Refactor' menu, check in there as well. A lot of those methods have been moved to the 'Refactor' menu in later versions of eclipse and if Zend has updated recently and not updated it's documentation, the items may have encountered an undocumented move.
#Omnipotent It's Zend Studio v6.01, "generate getters and setters" feature should be available. I can see doc about it in Help Contents.
By the way i'll try updating to v6.1
Thanks anyway!
EDITED: Templates and Code Assist works fine but are not usefull as "Generate getters and setters".