belcebur/belcebur-basic
Composer 安装命令:
composer require belcebur/belcebur-basic
包简介
Basic Tools from ZF2 + Doctrine + Gedmo Extension / Utilidades varias para ZF2 + Doctrine + Gedmo Extension
关键字:
README 文档
README
Require PHP >=7.0
-
Nl2brFilter
-
View Helper
-
Abstract Entity
-
Abstract Gedmo Entity
-
Abstract Repository
-
Abstract Gedmo Translatable Repository
Nl2brFilter
Añadir el filtro a los formularios
In your input filter configuration, add the nl2br filter to filter the result. An example form:
<?php 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( 'required' => true, 'filters' => array( array('name' => 'nl2br'), ), ), ); } }
View Helper
Inside view // En las Vistas
<?php /** * @var \BelceburBasic\View\Helper\BTools $btools */ $btools=$this->bTools(); $btools->getCurrentUrl(array $extraParams); //Get URL with params and add new params $btools->convertUrlQuery("test=1&temp=2"); //Returns the url query as associative array -> array("test"=>1,"temp"=>2); $btools->arrayToAttributes(array("test"=>1,"temp"=>2)); // Convert Array to html attributes -> test="1" temp="2"; $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
<?php return array( 'navigation' => array( 'bAdmin' => array(), // New Navigation 'default' => array(), //Standar Navigation ) );
Inside View / En las vistas
<?php echo $this->navigation()->breadcrumbs('admin'); ?> // To Create Breadcrumb <?php echo $this->navigation()->menu('admin')->setUlClass('nav navbar-nav'); ?> // To Create Menu
Abstract Doctrine Entity / Doctrine Entity abstracta
Add new search methods to your entity
Añade nuevos metodos de busqueda a tus entities
Example Custom Repository
<?php 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; }
Example Custom Repository With Gedmo Extensions Translatable
Gedmo Extensions Translatable https://github.com/Atlantic18/DoctrineExtensions
<?php 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; }
Included Methods/ Metodos Incluidos
ONLY GEDMO
getTranslatableLocale() setTranslatableLocale()
setFromArray(array $data)
----
<?php
/** Update User */
$user=$user->setFromArray(array('email'=> 'test@test.com'));
/** Create New User */
$user=User::setFromArray(array('email'=> 'test@test.com'));
----
fieldToSetterMethod($propertyName)
<?php $user->fieldToSetterMethod('email')
Output:
setEmail
fieldToGetterMethod($propertyName)
<?php $user->fieldToGetterMethod('email')
Output:
getEmail
toCamelCase
<?php $user->toCamelCase('email_and_name')
Output:
emailAndName
fromCamelCase
<?php $user->toCamelCase('emailAndName')
Output:
email_and_name
getProperty($propertyName)
<?php $user->getProperty('email') == $user->getEmail() == $user->email
Output:
toArray
<?php $array= $user->toArray();
Output:
<?php array( 'id' => 1, 'name' => 'David', 'email' => ..., )
extractGetMethods
List Getters
<?php array( getId getName getEmail )
extractSetMethods
List Setters
<?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
<?php namespace Application\Repository; use BelceburBasic\Resource\Doctrine\EntityRepository; /** * Class Event * * @package Application\Repository */ class Event extends EntityRepository { }
Example Gedmo Translations
If you use Gedmo Extensions Translatable https://github.com/Atlantic18/DoctrineExtensions, extend your repository from EntityRepositoryTranslatable and adds new search methods. It is not necessary to include the Gedmo Walker.
Si utiliza las Gedmo Extensions Translatable https://github.com/Atlantic18/DoctrineExtensions, extienda su repositorio de EntityRepositoryTranslatable y añada nuevos métodos de búsqueda. No es necesario incluir el Gedmo Walker.
<?php namespace Application\Repository; use BelceburBasic\Resource\Doctrine\Gedmo\EntityRepositoryTranslatable; /** * Class User * * @package Application\Repository */ class User extends EntityRepositoryTranslatable { }
Included Methods/ Metodos Incluidos
-
findNotBy(array $criteria, array $orderBy = NULL, $limit = NULL, $offset = NULL)
-
findOneNotBy(array $criteria)
-
findOrLikeBy(array $orCriteria, array $orderBy = NULL, $limit = NULL, $offset = NULL, $andCriteria = NULL)
-
findOneOrLikeBy(array $criteria)
-
findOneBy(array $criteria) //Only for Gedmo Extensions (Include Gedmo Walker on query)
-
findOneLikeBy(array $criteria)
-
findNotLikeBy(array $criteria, array $orderBy = NULL, $limit = NULL, $offset = NULL)
-
findBy(array $criteria, array $orderBy = NULL, $limit = NULL, $offset = NULL)
-
findLikeBy(array $criteria, array $orderBy = NULL, $limit = NULL, $offset = NULL)
belcebur/belcebur-basic 适用场景与选型建议
belcebur/belcebur-basic 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.6k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「orm」 「form」 「zf2」 「repository」 「gedmo」 「doctrine」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 belcebur/belcebur-basic 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 belcebur/belcebur-basic 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 belcebur/belcebur-basic 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LosLog provides some log utility
Kinikit - PHP Application development framework MVC component
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
EdpModuleLayouts is very simple Laminas module for making module-specific layouts insanely easy.
Diese Contao 4 Erweiterung stellt Google reCAPTCHA V2 in Form eines neuen Formularfeldes im Formulargenerator bereit. This extension provides Google reCAPTCHA V2 in the form of a new form field in the form generator of Contao Open Source CMS.
Zend Framework module to leverage the symfony dependency injection container
统计信息
- 总下载量: 1.6k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2015-08-17