1. Go to this page and download the library: Download stevecohenfr/ezseobundle 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/ */
stevecohenfr / ezseobundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new SteveCohenFR\EzSeoBundle\SteveCohenFREzSeoBundle(),
);
// ...
}
// ...
}
namespace ACME\ACMEBundle\SEO\Providers;
use SteveCohenFR\EzSeoBundle\SEO\Providers\AbstractProvider;
class ArticleProvider extends AbstractProvider
{
/**
* @override
*/
function getMetaTitle()
{
/* Get first defined attribute */
$metaTitle = $this->array_find([
$this->getContent()->getFieldValue('meta_title'),
$this->getContent()->getFieldValue('title')
], function($elem) {
return $elem != null && $elem != '';
});
return $metaTitle;
}
/**
* @override
*/
function getMetaDescription()
{
/* Get first defined attribute */
$metaDesc = $this->array_find([
$this->getContent()->getFieldValue('meta_description'),
$this->getContent()->getFieldValue('intro')->xml->textContent,
$this->getContent()->getFieldValue('catcher')->xml->textContent
], function($elem) {
return $elem != null && $elem != '';
});
return $metaDesc;
}
/**
* Return the first item that match the user provided callback
*/
private function array_find($xs, $f) {
foreach ($xs as $x) {
if (call_user_func($f, $x) === true)
return $x;
}
return null;
}
}
/**
* Get the current content
* @var \eZ\Publish\API\Repository\Values\Content\Content $content
*/
$content = $this->getContent();
/**
* Get eZ Platform Repository
* @var \eZ\Publish\Core\SignalSlot\Repository $repository
*/
$repository = $this->getRepository();
/**
* Get symfony Container
* @var \Symfony\Component\DependencyInjection\Container $container
*/
$container = $this->getContainer();
/**
* Get a service
* @var ACME\ACMEBundle\Services\MyService
*/
$myService = $container->get('my.service');
/**
* Get a parameter from ParametersBag
* @var string $myParam
*/
$myParam = $container->getParameter('my.parameter');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.