Giter Club home page Giter Club logo

admin-crud-silex's Introduction

admin-crud-silex

currently in development.

Installation

Using composer

Add following lines to your composer.json file:

Silex 2.2

Using fabpot/Silex-Skeleton

"require": {
  ...
  "mwsimple/admin-crud-silex": "2.2.*@dev"
}

Execute:

php composer.phar update "mwsimple/admin-crud-orm-silex"

Dependencies

Using doctrine

Usage

Add it to the src/Controller/PostController.php class:

<?php
namespace Controller;

use MWSimple\Silex\AdminCrudSilex\CrudController;

class PostController extends CrudController
{
}

Add it to the src/app.php class:

use Silex\Application;
...
use Controller\PostController;
...
//CONTROLLER POST
$app['post.controller'] = $app->share(function() use ($app) {
    $options = array(
    	'dirTemplate' => 'Post/',
    	'table' => 'post'
    	'route' => 'post'
    );
    return new PostController($app,$options);
});

Add it to the src/controllers.php class:

...
use Symfony\Component\HttpFoundation\Request;

Request::enableHttpMethodParameterOverride();
...
...
//CONTROLLER POST
$app->get('/post', "post.controller:indexAction")->bind('post');
$app->post('/post/', "post.controller:createAction")->bind('post_create');
$app->get('/post/new', "post.controller:newAction")->bind('post_new');
$app->get('/post/{id}', "post.controller:showAction")->bind('post_show');
$app->get('/post/{id}/edit', "post.controller:editAction")->bind('post_edit');
$app->post('/post/{id}', "post.controller:updateAction")->bind('post_update')
  ->method('PUT|POST')
;
$app->delete('/post/{id}', "post.controller:deleteAction")->bind('post_delete')
  ->method('DELETE')
;

Add it to the src/Controller/ConfigController.php class:

<?php
namespace Controller;

abstract class ConfigController
{
    static function createForm($table, $app, $entity)
    {
        switch ($table) {
//post
            case 'post':
                $form = $app['form.factory']->createBuilder('form', $entity)
                    ->add('title')
                    ->getForm()
                ;
                break;
            default:
                $form = null;
                break;
        }
        return $form;
    }

    static function createList($table)
    {
        switch ($table) {
//post
            case 'post':
                $list = array('id','title');
                break;
            default:
                $list = array('id');
                break;
        }
        return $list;
    }

    static function createShow($table)
    {
        switch ($table) {
//post
            case 'post':
                $show = array('id','title','description', 'content');
                break;
            default:
                $show = array('id');
                break;
        }
        return $show;
    }
}

copy the contents of the folder AdminCrudSilex/Resources/public/admin-crud-silex/* to web/admin-crud-silex/

copy the contents of the folder AdminCrudSilex/Resources/crudViews/* to templates/crudViews/

Author

Gonzalo Alonso - [email protected]

admin-crud-silex's People

Contributors

gonzaloalonsod avatar

Watchers

James Cloos avatar Alejandro Pereyra avatar

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.