-
Notifications
You must be signed in to change notification settings - Fork 8
Add, remove and move #17
Add, remove and move #17
Conversation
Looks good! will have a proper look later on. |
|
||
$resolvedPath = $this->resolvePath($query); | ||
|
||
$this->removeResource($resolvedPath, $deleted); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this to:
return $this->removeResource($resolvedPath);
and have removeResource
simply return the number of items deleted?
hey @dantleech i did the changes you whant me to do, but i think the thing with the path isn't correct. The injected path can not be the destination path. otherwise adding of a collection of resources will completly wrong. Lets do an example:
|
|
||
$document = $resource->getPayload(); | ||
$document->setName($resource->getName()); | ||
if ($document instanceof HierarchyInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documents do not require a "name" method, they also do not need to implement the HierearchyInterface
in order to have a parent, nor would they necessarily have either a "parent" or a "name" mapping as they could be using an "ID/path" ID strategy (where you would set the path directly).
In the Syluus resource bundle I force the user to use the name
and parent
mappings, but that could be more flexible.
I am not even sure it makes sense to be able to create documents here at all - you cannot gaurantee that a document doesn't have required fields which cannot be set using this API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think creation and validation of fields/properties should be done outside. i.e. in a controller of rest-resources-bundle - the point where in the input will be created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently creation and edition would be/is done either by SonataAdmin or SyliusResourceBundle - which supports both HTML and REST endpoints for editing and creating new objects.
I see the Resource system as providing links to these endpoints which are capable of dealing with the resource's payload.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we should open complete CRUD endpoints on Phpcr and PhpcrOdm here (over resource-rest-bundle) on the complete node/documents to enable all frontend applications like admins, to work on the path based structure. The content-bundle would give a REST endpoint on based on the content's route (and the dynamic routing) to have CRUD on content only. a use case would be the frontend editing. That would be my big picture in 4 lines :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the above code.
We don't even need to set the name
or parent
. We are being passed the payload - i.e. the document. It should already be ready-to-persist without further modification or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On reflection -- what is the use case for "add" ? With both the ODM and PHPCR the class/node-types may require fields which cannot be set by simply creating a Document/Node. |
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message
I am still not sure of why we need |
|
||
$resolvedPath = $this->resolvePath($query); | ||
|
||
return $this->removeResource($resolvedPath, $deleted); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing deleted
does not make any sense.
Will work on the rest of the hints tonight. |
/** | ||
* @author Maximilian Berghoff <[email protected]> | ||
*/ | ||
class FalsyResource implements PuliResource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use GenericResource
here?
@ElectricMaxxx would you mind if i fork this PR and merge only the After move and remove are merged this PR will just be about |
👍 can you do same for the bundle?
|
Will do |
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function remove($query, $language = 'glob') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ElectricMaxxx I think this is for removing multiple resources? But we are only removing one?
Forked and replaced by: #23 |
This PR does the implemenetation of the the base methods of the
EditableRepository
in both repositories. We will hopefully get the move method when puli/repository#26 is ready, but i will start with it before the merge and use the interface defined by @wouterjToDo:
Note: i branched from the state #15 will rebase on master when its merged, so the other commits should disappear.