<commit_before><?php
/**
 * ZucchiDoctrine (http://zucchi.co.uk)
 *
 * @link      http://github.com/zucchi/ZucchiDoctrine for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zucchi Limited. (http://zucchi.co.uk)
 * @license   http://zucchi.co.uk/legals/bsd-license New BSD License
 */
namespace ZucchiDoctrine\View\Helper;

use Zend\View\Helper\AbstractHelper;
use ZucchiDoctrine\Entity\AbstractEntity;
use Doctrine\ORM\Mapping\ClassMetadata;

/**
 * return an appropriate value based upon field type
 *
 * @package    ZucchiDoctrine
 * @subpackage View
 * @category Helper
 */
class EntityField extends AbstractHelper
{
    /**
     * Truncate input text
     *
     * @param AbstractEntity $entity
     * @param string $field
     * @param
     * @return mixed
     */
    public function __invoke(AbstractEntity $entity, $field, ClassMetadata $metadata = null)
    {
        if (strpos($field, '->')) {
            list($Assoc, $field) = explode('->',$field, 2);
            return $this->__invoke($entity->{$Assoc}, $field);

        } else {
            if (property_exists('__isInitialised__',$entity) && $entity->__isInitialized__) {
                // entity is an uninitialised proxy, lets load it
                $entity->load();
            }
            if (!isset($entity->{$field})) {
                throw new \RuntimeException('Field "' . $field . '" not found in Entity: ' . get_class($entity));
            }

            $value = $entity->{$field};

            if ($metadata) {
                if ($column = $metadata->getFieldMapping($field)) {
                    switch (strtolower($column['type'])) {
                        case "money":
                            $value = $this->getView()->currencyFormat($value, 'GBP');
                            break;
                        case "datetime":<commit_msg>updated entityField Helper to allow recursion<commit_after><?php
/**
 * ZucchiDoctrine (http://zucchi.co.uk)
 *
 * @link      http://github.com/zucchi/ZucchiDoctrine for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zucchi Limited. (http://zucchi.co.uk)
 * @license   http://zucchi.co.uk/legals/bsd-license New BSD License
 */
namespace ZucchiDoctrine\View\Helper;

use Zend\View\Helper\AbstractHelper;
use ZucchiDoctrine\Entity\AbstractEntity;
use Doctrine\ORM\Mapping\ClassMetadata;

/**
 * return an appropriate value based upon field type
 *
 * @package    ZucchiDoctrine
 * @subpackage View
 * @category Helper
 */
class EntityField extends AbstractHelper
{
    /**
     * Truncate input text
     *
     * @param AbstractEntity $entity
     * @param string $field
     * @param
     * @return mixed
     */
    public function __invoke(AbstractEntity $entity, $field, ClassMetadata $metadata = null)
    {
        if (strpos($field, '.')) {
            list($Assoc, $field) = explode('.',$field, 2);
            return $this->__invoke($entity->{$Assoc}, $field);

        } else {
            if (property_exists('__isInitialised__',$entity) && $entity->__isInitialized__) {
                // entity is an uninitialised proxy, lets load it
                $entity->load();
            }
            if (!isset($entity->{$field})) {
                throw new \RuntimeException('Field "' . $field . '" not found in Entity: ' . get_class($entity));
            }

            $value = $entity->{$field};

            if ($metadata) {
                if ($column = $metadata->getFieldMapping($field)) {
                    switch (strtolower($column['type'])) {
                        case "money":
                            $value = $this->getView()->currencyFormat($value, 'GBP');
                            break;
                        case "datetime":
{'fraction_non_alphanumeric': 0.13774693005872932, 'fraction_numerical': 0.004805125467164976, 'mean_word_length': 2.1381909547738696, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1207459', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1030, 'n_words': 240}