Code Monkey home page Code Monkey logo

resource's Introduction

This repository is no longer maintained

Due to lack of interest, we had to decide to discontinue this repository. The CMF project focusses on the Routing component and RoutingBundle, which are still in active use by other projects.

This repository will no longer be upgraded and marked as abandoned, but will be kept available for legacy projects or if somebody wants to experiment with the CMF.

You can contact us in the #symfony_cmf channel of the Symfony devs slack.

Symfony CMF Resource

Latest Stable Version Latest Unstable Version License

Total Downloads Monthly Downloads Daily Downloads

Branch Travis Coveralls
master Build Status Coverage Status

This package is part of the Symfony Content Management Framework (CMF) and licensed under the MIT License.

The Resource component provides PHPCR/ODM integration with Puli.

CAUTION As Puli is not yet stable, the complete component is marked internal. Backwards compatibility of upcoming 1.x versions is not guaranteed.

Requirements

  • PHP 7.1 / 7.2
  • Symfony
  • See also the require section of composer.json

Documentation

For the install guide and reference, see:

See also:

Support

For general support and questions, please use StackOverflow.

Contributing

Pull requests are welcome. Please see our CONTRIBUTING guide.

Unit and/or functional tests exist for this package. See the Testing documentation for a guide to running the tests.

Thanks to everyone who has contributed already.

License

This package is available under the MIT license.

resource's People

Contributors

dantleech avatar dbu avatar electricmaxxx avatar lsmith77 avatar wouterj avatar xabbuh avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

resource's Issues

Doctrine ORM "sharded" repository.

We could support the Doctrine ORM by using "sharding" based on table fields to provide a hierarchy.

By providing a list of SQL field specifications we should be able to emulate a
hierarchy.

cmf_repository:
    repositories:
        invoices_by_date:
            # e.g. /2016/06/SYMCMF-01
            type: doctrine_orm_sharded
            class: AppBundle\Entity\Invoice
            name: {{ clientRef }}-{{ invoiceNo }} # property access

            # in SQL
            shards:
                - "DATE(date)"
                - "MONTH(date)"
        invoices_by_client:
            # e.g. /SYMCMF/00001
            type: doctrine_orm_sharded
            class: AppBundle\Entity\Invoice
            name: {{ invoiceNo }}

            # in SQL
            shards:
                - "clientRef"

        default:
            # mount in a composite e.g.
            #
            #   articles/
            #      ...
            #   invoices/
            #     date/
            #       2016/
            #         06/
            #           SYMCMF-0001
            #     client/
            #       SYMCMF/
            #         0001
            #  
            ty: composite
            mount:
                - 
                    repository: invoices_by_date
                    mountpoint: "/invoices/bydate"
                -
                    repository: invoices_by_client
                    mountpoint: "/invoices/byclient"
                -
                    repository: articles # f.e.
                    mountpoint: "/articles"

Alternative Description architecture

We could use objects for the Descriptors and access them by their class name:

$description->addDescriptor(new HtmlLinksDiscriptor([
    HtmlLinksDescriptor::EDIT => '/path/to/edit/1',
    HtmlLinksDescriptor::REMOVE => '/path/to/remove/1',
    // ...
]);

$description->addDescriptor(new ChildClassesDescriptor([
     FooClass::class,
     BarClass::class
]);


$linkUrl = $description->getDescriptor(HtmlLinksDescriptor::class)->getEditUrl();

if ($description->hasDescriptor(ChildClassesDescriptor::class)) {
    $childClasses = $description->getDescriptor(ChildClassesDescriptor::class)->getChildClasses();
}

It can then be assumed that if the client is requesting the descriptor by class name, that they know what to do with it (i.e. it can have its own public API).

Unfortunately this is very verbose in Twig:

<h1>Hello</h1>
<a href="{{ description.hasDescriptor('Name\Space\Descriptor\HtmlLinksDescriptor') ? description.descriptor('Name\Space\Descriptor\HtmlLinksDescriptor').editLink }}">Edit</a>

This approach solves the current ambiguity problem posed by having a simple key/value store, but increases the verbosity, especially in Twig and when consumed through the REST service.

Move admin enhancers out of here.

The Sonata Enhancer can live in the as-yet-not-existing CmfSonataAdminBundle.

The Sylius Enhancer should live in an equivilent place.

These are integration enhancers, and should be part of an integration package which has all of the relevant dependencies.

Dependency: SyliusResourceBundle

sylius/resource-bundle should go into require section of composer.json or the SyliusEnhancer has to be enabled when available only

Default registry

Allow retrieval of default registry, or if no default set, the first registry in the event that ->getRegistry() is called with an empty value.

Alternatively always throw an exception and put the responsiblity for resolving registries on the consumer.

Standardize the retrieval of URLs relating to a specific resource.

The ResourceRestBundle currently has the concept of "enhancers" which add
fields such as the URL to edit or create the underlying resource payload.

I would like to push this back a level: this information is useful more
gernerally, for example when building an admin interface that doesn't need REST
and where you need the edit/view/create/delete URLs.

Puli already has the concept of Metadata but it is metadata from the
resource, we want metadata which is "over" the resource - i.e. the URLs of the
admin system.

So I am proposing something like:

class SonataMetadata implements HtmlAdminMetadataInterface
{
   /**
    * Return the edit URL for the resources payload.
    *
    * @return string|null
    */
   public function getHtmlEditUrl();

   /**
    * Return the remove URL for the resources payload.

    * @return string|null
    */
   public function getHtmlRemoveUrl();

   /**
    * Return the add URL for the resources payload using this item as a parent.

    * @return string|null
    */
   public function getHtmlAddChildUrl();
}

or:

class SyliusMetadata implements AdminMetadataInterface
{
    public function __construct(Router $router)
    {
        // ... 
    }

    public function supports()
    {
        return [
            AdminMetadata::HTML_EDIT,
            AdminMetadata::HTML_REMOVE,
            AdminMetadata::HTML_ADD_CHILD,
            AdminMetadata::REST_CREATE,
            AdminMetadata::REST_REMOVE,
        ];
    }

    public function get($name)
    {
         switch ($name) {
             case AdminMetadata::HTML_EDIT:
                  return $this->router->generate(' ... ');
                  break;
        }

        throw ..
    }
}

Where we would have a factory system using drivers similar to the current SonataEnhancer in the ResourceRestBundle.

Very much open to other ideas.

/cc @wouterj @dbu @lsmith77

Mutable resources

I think it makes sense for Resource's to be mutable.

This would facilitate, for example, modifications to be made from a Tree view (using elfinder / jstree, whatever).

This is what the Apache Sling ResourceProvider does.

Re-order interface / method

CMS resources are orderable, in addition to the EditableRepository methods we need to be able to change the order of resources.

I currently suggest adding this to the CmfEditableRepository interface being added in #17.

public function reorder($sourcePath, $destPath, $before = false);

or

public function orderBefore($sorucePath, $destPath);
public function orderAfter($sourcePath, $destPath);

Support saving resource payloads?

I am currently writing a CRUD which accepts the resource repository and path as request parameters.

/{repository}/{path}/edit

A form is then obtained from the ether for the (CmfResource) payload. When the form is submitted the resource payload needs to be updated.

I am currently doing this throguh a separate "agent" system (currently only concerned with save, as finding is taken care of by this component).

  • Adding a save/savePayload method for a ResourceRepository would be quite trivial at this layer

I am just wondering if it is a good idea or if it would be a can of worms for some reason.

WebDAV support / Mutable body

I wonder to what extent we could support WebDAV, for example via

https://github.com/fruux/sabre-dav

Ultimately this would allow people to mount the repository tree locally as a filesystem.

If we support [get|set]Body then we could support remote authoring / template design.

For example if Twig templates could be stored in the ORM, PHPCR-ODM or even on the filesystem (!). A document/entity would only need to implement a MutableBody interface and a designer could modify remote templates in a local editor.

Extract Description into separate component.

All of the current desciption enhancers act upon the Payload - i.e. they don't really care about the resource.

This is not to say that enhancers can't act on the resource itself (e.g. actual files) but just that currently none of the do.

We can extract the Description stuff into a separate component that acts upon objects of any type, not just PuliResource instances.

CmfResource instances can still be supported - we just make a PuliResource enhancer which is a "proxy" to the descrition for the payload and other Puli resources (e.g. FileResource) can still be handled.

Remove `Description` functionality.

The current "description" system can be very easily generalized to act on objects instead of Puli resources.

I have created a description component and bundle, and also an enhancer for doctrine phpcr odm.

So I would suggest using this. The only difference is that the enhancers are not registered by the bundle and should be registered by the user.

(also note that all of the above is, as with this component, under development).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.