0

I have a user table with a store id column (store) that correspondent with a store table. I'm retrieving this store id with a custom entity object.

Application/Entity/User.php

namespace Thuiswinkelen\Entity;

class User extends \ZfcUser\Entity\User
{

/**
 * @var int
 */
protected $store;


public function getStore()
{
    return $this->store;
}

/**
 * Set store.
 *
 * @param int $store
 * @return UserInterface
 */
public function setStore($store)
{
    $this->store = (int) $store;
    return $this;
}


}

My question is: How to get the store name in the store table (with an inner join?) It would be great when I can use something like:

<?php echo $this->zfcUserStoreId() ?> 
<?php echo $this->zfcUserStoreName() ?>
Royw
  • 599
  • 5
  • 24

1 Answers1

0

If you're looking to map entity relationships; you will need an object relational mapper (ORM), such as Doctrine to accomplish this.

This will convert your foreign identifiers into objects in which you can then transverse.

$storeName = $user->getStore()->getName();

I'm guessing that the examples you have suggested $this->zfcUserStoreId() you have invented due to the already existing ZfcUser\View\Helper\ZfcUserDisplayName

This however is a view helper and simplify aids the rendering of a user's name based on other configuration.

AlexP
  • 9,906
  • 1
  • 24
  • 43
  • I've setup Doctrine and it's working correctly (very useful!). But I do not get it working with getName(); I want to show the store name in the layout. What do I have to do with the $user variabele you showed me? – Royw May 29 '14 at 11:20