PHP code example of belcebur / belcebur-basic

1. Go to this page and download the library: Download belcebur/belcebur-basic library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

belcebur / belcebur-basic example snippets


namespace Application\Form;

use Zend\InputFilter;
use Zend\Form\Form;

class Foo extends Form implements
    InputFilter\InputFilterProviderInterface
{
    public function __construct($name = null)
    {
        parent::__construct($name);

        $this->add(array(
            'name'    => 'text',
            'options' => array(
                'label' => 'Text'
            ),
            'attributes' => array(
                'type'  => 'textarea',
            ),
        ));
    }

    public function getInputFilterSpecification()
    {
        return array(
            'text'  => array(
                '

$btools->getParams(); // Get RouteMatch Params

$btools->getParam($name,$default); // Get RouteMatch Param or Default

$btools->slugify("حولا كيو تل"); //        ->           'hwla-kyw-tl'
$btools->slugify("你好,这样的"); //             ->   'ni-hao-zhe-yang-de'
$btools->slugify("그러한 안녕하세요"); //          ->       'geuleohan-annyeonghaseyo'
$btools->slugify("त्यस्तो नमस्ते");  //    ->           'tyasto-namas'
$btools->slugify("hola que tal"); //       ->           'hola-que-tal'
$btools->slugify("привет, что такой");//   ->               'privet-cto-takoj'

Same with Static Method

BTools::SlugifyStaticPro("حولا كيو تل"),
BTools::SlugifyStaticPro("你好,这样的"),
BTools::SlugifyStaticPro("그러한 안녕하세요"),
BTools::SlugifyStaticPro("त्यस्तो नमस्"),
BTools::SlugifyStaticPro("hola que tal"),
BTools::SlugifyStaticPro("привет, что такой")


// And Getters from:


    /**
     *
     * @var \Zend\Http\PhpEnvironment\Request
     */
    protected $request;
    /**
     *
     * @var \Zend\Mvc\MvcEvent
     */
    protected $event;

    /**
     * @var \Doctrine\ORM\EntityManager
     */
    protected $em;

    /**
     * @var \Zend\Mvc\I18n\Translator
     */
    protected $translator;


    /**
     * @var \Zend\ServiceManager\ServiceManager
     */
    protected $serviceManager;

    /**
     * @var \Zend\View\HelperPluginManager
     */
    protected $pluginManager;


    /**
     * @var \Zend\Mvc\Application
     */
    protected $app;

----


== Create Other Zend Navigation

Inside config file. / En un archivo de configuración

http://framework.zend.com/manual/current/en/tutorials/tutorial.navigation.html

[source,php]
----

return array(
    'navigation'      => array(
        'bAdmin'  => array(), // New Navigation
        'default' => array(), //Standar Navigation
    )
);

----

Inside View / En las vistas

[source,php]
----

 echo $this->navigation()->breadcrumbs('admin'); 
 echo $this->navigation()->menu('admin')->setUlClass('nav navbar-nav'); 



namespace Application\Entity;

use BelceburBasic\Resource\Doctrine\Entity;
use Doctrine\ORM\Mapping as ORM;

/**
 * Class Entity
 *
 * @package Application\Entity
 */
class User extends Entity {

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

     /**
     * @var string
     *
     * @ORM\Column(name="email", type="string", length=100, nullable=false)
     */
    protected $email;



namespace Application\Entity;

use BelceburBasic\Resource\Doctrine\Gedmo\EntityTranslatable;
use Doctrine\ORM\Mapping as ORM;

/**
 * Class Entity
 *
 * @package Application\Entity
 */
class User extends EntityTranslatable {

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

     /**
      * @var string
      *
      * @Gedmo\Translatable()
      * @ORM\Column(name="name", type="string", length=100, nullable=false)
      */
     protected $name;


 /** Update User */
 $user=$user->setFromArray(array('email'=> '[email protected]'));

 /** Create New User */
  $user=User::setFromArray(array('email'=> '[email protected]'));
 ----

==== fieldToSetterMethod($propertyName)
[source,php]
----

$user->fieldToSetterMethod('email')
----

===== Output:
setEmail

==== fieldToGetterMethod($propertyName)
[source,php]
----

$user->fieldToGetterMethod('email')
----

===== Output:
getEmail

==== toCamelCase
[source,php]
----

$user->toCamelCase('email_and_name')
----

===== Output:
emailAndName

==== fromCamelCase
[source,php]
----

$user->toCamelCase('emailAndName')
----

===== Output:
email_and_name


==== getProperty($propertyName)
[source,php]
----

$user->getProperty('email') == $user->getEmail() == $user->email
----

===== Output:

==== toArray
[source,php]
----


$array= $user->toArray();

----

===== Output:
[source,php]
----

array(
    'id' => 1,
    'name' => 'David',
    'email' => ...,
)
----

==== extractGetMethods

List Getters
[source,php]
----

array(
    getId
    getName
    getEmail
)
----

==== extractSetMethods

List Setters
[source,php]
----

array(
    setId
    setName
    setEmail
)
----



== Abstract Repositories / Repositorios Abstractos

Add new search methods to your repositories

Añade nuevos metodos de busqueda a tus repositorios

== Example Custom Repository

[source,php]
----



namespace Application\Repository;

use BelceburBasic\Resource\Doctrine\EntityRepository;

/**
 * Class Event
 *
 * @package Application\Repository
 */
class Event extends EntityRepository {


namespace Application\Repository;

use BelceburBasic\Resource\Doctrine\Gedmo\EntityRepositoryTranslatable;

/**
 * Class User
 *
 * @package Application\Repository
 */
class User extends EntityRepositoryTranslatable
{