Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not determine access type for property #1949

Closed
ibasaw opened this issue Nov 30, 2017 · 8 comments
Closed

Could not determine access type for property #1949

ibasaw opened this issue Nov 30, 2017 · 8 comments

Comments

@ibasaw
Copy link

ibasaw commented Nov 30, 2017

SF4.0
php 7.1
easy_admin:
    entities:
        - App\Entity\Player

i use this trait in an entity named Player

<?php

namespace App\Traits;

use Doctrine\ORM\Mapping as ORM;

trait createdAt
{
    /**
     * @ORM\Column(name="created_at", type="datetime", nullable=true)
     */
    protected $createdAt;

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     *
     * @return createdAt
     */
    public function setCreatedAt()
    {
        $this->createdAt = new \DateTime('now');

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }
}

i had created a new Player item with this entity/trait but when i want to save to DB, i got this error:

Could not determine access type for property "createdAt" in class "App\Entity\Player".

@duraki
Copy link

duraki commented Dec 22, 2017

Same here, did you manage to fix it?

This is my code:

/**
 * @var \DateTIme
 * 
 * @ORM\Column(name="created_at", type="datetime", nullable=false)
 */
private $createdAt;

/**
 * @var \DateTIme
 * 
 * @ORM\Column(name="updated_at", type="datetime", nullable=true)
 */
private $updatedAt;

function __construct() {
    $this->updatedAt = $this->createdAt = new \DateTime();
...

No setters but same when I add them.

@xabbuh
Copy link
Collaborator

xabbuh commented Dec 22, 2017

@duraki In your case, adding a getter and setter method for the property should solve the issue.

@duraki
Copy link

duraki commented Dec 22, 2017

@xabbuh I've already had getters but when I add setters I'm getting the same result, just as I said. Thanks for the suggestion tho.

@xabbuh
Copy link
Collaborator

xabbuh commented Dec 22, 2017

Can one of you create an example application that allows to reproduce the issue?

@duraki
Copy link

duraki commented Dec 26, 2017

@xabbuh yes, I'll need some time but I'll sure ping you back asap

@rampmaster
Copy link

@javiereguiluz i can replicated the error. The problem is in vendor/symfony/property-access/PropertyAccessor.php (line 543) not in library. @ibasaw the solution is change trait with inheritance.
Regards

@javiereguiluz
Copy link
Collaborator

I'm closing this issue because we're starting a new phase in the history of this bundle (see #2059). We've moved it into a new GitHub organization and we need to start from scratch: no past issues, no pending pull requests, etc.

I understand if you are angry or disappointed by this, but we really need to "reset" everything in order to reignite the development of this bundle.

@ssmusoke
Copy link

@rampmaster I am facing the same issue, what does "change trait with inheritance" mean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants