1. Go to this page and download the library: Download kyoushu/common-bundle 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/ */
kyoushu / common-bundle example snippets
$bundles = array(
// ...
new Kyoushu\CommonBundle\KyoushuCommonBundle(),
// ...
);
namespace AppBundle\Entity;
use Kyoushu\CommonBundle\Upload\UploadInterface;
use Symfony\Component\HttpFoundation\File\File;
class MyUploadEntity implements UploadInterface
{
/**
* @var File|null
*/
protected $file;
/**
* @var string|null
*/
protected $relPath;
/**
* @return File|null
*/
public function getFile()
{
return $this->file;
}
/**
* @param File|null $file
* @return $this
*/
public function setFile(File $file = null)
{
$this->file = $file;
return $this;
}
/**
* @return string|null
*/
public function getRelPath()
{
return $this->relPath;
}
/**
* @param string|null $relPath
* @return $this
*/
public function setRelPath($relPath)
{
$this->relPath = $relPath;
return $this;
}
/**
* @return string
*/
public function getRelDir()
{
return 'sub/dir/where/upload/should/go';
}
}
namespace AppBundle\Entity;
use Kyoushu\CommonBundle\Entity\Traits as EntityTraits;
class MyEntity
{
// Provides the property $id (auto-incrementing primary key) and related getter
use EntityTraits\IdTrait;
// Provides the properties $title and $slug and related getters/setters
// - $slug is generated from the value of $title on persist/update
use EntityTraits\TitleSlugTrait;
// Provides the $summary property and related getters/setters
// - Intended to be used with textarea form fields
use EntityTraits\SummaryTrait;
// Provides $created and $updated timestamp properties and related getters/setters
// - $created is set to \DateTime('now') on persist
// - $updated is set to \DateTime('now') on persist/update
use EntityTraits\TimestampTrait;
}
namespace AppBundle\EntityFinder;
use Kyoushu\CommonBundle\EntityFinder\AbstractEntityFinder;
class MyEntityFinder extends AbstractEntityFinder
{
public function getEntityClass()
{
return 'AppBundle\Entity\MyEntity';
}
}
namespace AppBundle\EntityFinder;
use Kyoushu\CommonBundle\EntityFinder\AbstractEntityFinder;
class MyEntityFinder extends AbstractEntityFinder
{
protected $title;
public function getEntityClass()
{
return 'AppBundle\Entity\MyEntity';
}
public function getTitle()
{
return $this->title;
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function getRouteParameterKeys()
{
return array('page', 'perPage', 'title');
}
public function configureQueryBuilder(QueryBuilder $queryBuilder)
{
$title = $this->getTitle();
if($title !== null){
$queryBuilder->andWhere('entity.title like :like_title');
$queryBuilder->setParameter('like_title', '%' . $title . '%');
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.