comradepoison comradepoison - 7 months ago 12
SQL Question

Method for Object does not exist?

I am new to symfony2 I'm trying to create a search function and got this


error 'Method "ediTransaction" for object "Matrix\MatrixEdiBundle\Entity\Edi997SegmentInError" does not exist in MatrixEdiBundle:Matrix:rejectedTrans.html.twig at line 58'


is it what problem is it? Anyone?

Repository

class Edi997DetailsRepository extends EntityRepository{
public function getDetails($gsNumber, $senderId, $receiverId, $page = 1, $limit = 5 ){

$em = $this->getEntityManager();

$query = $em->createQuery(

'SELECT partial a.{id, ak301, ak401},
partial b.{errorCode, condition},
partial c.{edi997DetailId, errorCodeId, noOfTrans},
partial d.{ediTransactionId, senderId, receiverId, gsNumber, isaNumber, fileName}
FROM MatrixEdiBundle:Edi997SegmentInError a
JOIN a.ediAk403ErrorCodes b
JOIN a.edi997Details c
JOIN c.ediTransaction d
WHERE d.gsNumber LIKE :gsNumber
AND d.senderId LIKE :senderId
AND d.receiverId LIKE :receiverId
AND c.errorCodeId != 1
AND d.flag = 1')
->setParameter('gsNumber', "%$gsNumber%")
->setParameter('senderId', "%$senderId%")
->setParameter('receiverId', "%$receiverId%")
->setFirstResult(($page-1)*$limit)
->setMaxResults($limit);

$paginator = new Paginator($query, $fetchJoinCollection = false );

$paginator->setUseOutputWalkers(false);

return $paginator;
}
}


Twig :

{% if transaction != null %}
{% for trans in transaction %}
<tr>
<td style="width: 11%;">
{{ render(controller('MatrixEdiBundle:Matrix:getTradingPartnerName', {'timexID' : trans.ediTransaction.receiverId, 'customerID' : trans.ediTransaction.senderId})) }}
</td>

{%
set result=render(controller('MatrixEdiBundle:Matrix:getFile', {'fileName' : trans.ediTransaction.fileName, 'senderId': trans.ediTransaction.receiverId , 'receiverId' : trans.ediTransaction.senderId }))|split('+', 4)
%}

<td style="width: 10%;">{{ result[0] }}</td>
<td style="width: 40%;">{{ result[3] }}<br><br>
{% if trans.errorCodeId == 2 %}
<span style="background-color: yellow;">Accepted but <br/>errors were <br/>noted</span><br/>
{% elseif trans.errorCodeId == 3 %}
<span style="background-color: yellow;">Partially<br/> Accepted</span><br/><br/>
{{ trans.acceptedTrans }} Accepted,<br/>
{{ trans.noOfTrans - trans.acceptedTrans }} Rejected
{% else %}
<span style="background-color: yellow;">Rejected</span>
{% endif %}
<br/>

{%
set error=render(controller('MatrixEdiBundle:Matrix:getError', {'id': trans.edi997DetailId }))|split('+')
%}
<span>
<p style="white-space: normal;">
{% if error[0] != "0" %}
{{ error[0] }}{{ "%02d"|format(error[1]) }}<br/>
{{ error[2] }}
{% else %}
Errors were not specified in 997 file
{% endif %}
</p>
</span>
</td>
<td style="width: 10%;">{{ result[2] }}</td>
<td style="width: 7%;">{{ result[1] }}</td>
<td style="width: 5%;">{{ trans.noOfTrans }}</td>
<td style="width: 7%;">{{ trans.ediTransaction.receiverId }}</td>
<td style="width: 8%;">{{ trans.ediTransaction.senderId }}</td>
<td>
<a href="" data-href="{{ path('matrix_edi_deleteFile', { 'id':trans.ediTransaction.ediTransactionId,'filename': trans.ediTransaction.fileName, 'url': 'matrix_edi_rejectedOutboundTrans' }) }}" data-toggle="modal" data-target="#confirm-delete"><center><i class="fa fa-trash o" style="color:#1975A3;"></i></center></a>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="15" class="alignment result"> No Result Found </td>
</tr>
{% endif %}

Answer

The answer is in the error.

In your Edi997SegmentInError entity object, there is no ediTransaction method.

Probable causes:

  1. The method doesn't exist in any object
  2. The method exists in an object, just not the one you're accessing

Looking at your repository method, that seems to be in your Edi997Details entity.

Presumably you'd access it via {{trans.edi997Details.ediTransaction.receiverId}} - but I'm really guessing there - you have to follow your object hierarchy correctly in twig. If you're not sure exactly which object you're accessing, try using {{dump(trans)}} to see what you have.

Comments