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

Cannot Filter Array of Objects on Array of Objects #63

Open
bobdercole opened this issue Feb 1, 2017 · 2 comments
Open

Cannot Filter Array of Objects on Array of Objects #63

bobdercole opened this issue Feb 1, 2017 · 2 comments

Comments

@bobdercole
Copy link
Contributor

Hello,

I am trying to filter an array of objects with the Native target. The objects that I am trying to filter contain an array of objects. When I try to filter the array, I get a property access exception:

Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException(code: 0): Cannot read property "name" from an array. Maybe you intended to write the property path as "[name]" instead.

Here is a simplified snippet of my objects:

class Label
{
	public $name = 'something';
}

class User
{
	public $labels;

	public function __construct()
	{
		$this->labels = [
			new Label(),
			new Label(),
			new Label()
		];
	}
}

Here is a snippet of my RulerZ specification:

class UserLabelsNameSpecification implements Specification
{
	public function getRule()
	{
		return 'labels.name = "something"';
	}
}

Here is the filter:

$users = [
	new User(),
	new User(),
	new User()
];

$filtered_users = $rulerz->filterSpec($users, new UserLabelsNameSpecification());

Is RulerZ supposed to support this? Perhaps I'm doing something wrong? I could not find an example of this situation. My example works fine with the DoctrineOrm target.

@filisko
Copy link

filisko commented May 26, 2019

I had the same problem... I guess that we will need to create our own executors to cover that case.

@xfifix
Copy link

xfifix commented Dec 13, 2019

@filisko @bobdercole i have the same problem, can you show your executor ?

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

No branches or pull requests

3 participants