1. Go to this page and download the library: Download nucivic/dkanextension 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/ */
nucivic / dkanextension example snippets
namespace Drupal\DKANExtension\Context;
use Behat\Gherkin\Node\TableNode;
/**
* Defines application features from the specific context.
*/
class MyEntityContext extends RawDKANEntityContext{
public function __construct(){
parent::__construct(array(
// These are the mappings of human readable name => drupal field machine name or entity property name.
'title' => 'title',
'author' => 'author',
'myfield' => 'field_my_field'
),
// This is the bundle name if one exists, or null if one doesn't.
// for nodes bundle == node_type name
'myentity',
// This is the entity type.
'node'
);
}
/**
* @Given myentities:
*/
public function addDataDashboard(TableNode $dashboardtable){
//This is an example of calling parent helper functions.
parent::addMultipleFromTable($dashboardtable);
}
/**
* A contrived exmple of hooking into the Entity helpers by overriding them.
*
* Set all of the entities to be unpublished before they're created, no matter what.
*/
public function wrap($entity){
$wrapper = parent:wrap($wrap);
$wrapper->status = 0;
return $wrapper;
}
/**
* @Given myentities:
*
* All custom entities will almost all want to add this type of function.
*/
public function addDataDashboard(TableNode $dashboardtable){
//This is an example of calling parent helper functions.
parent::addMultipleFromTable($dashboardtable);
}
/**
* @Given there should be ":number" MyEntities.
*
* An example showing how you can creat new step functions and get the entities array from the parent class.
*/
public function assertNumberEntities($number){
$actual = count($this->entities);
if ($number !== count($this->entities) {
throw new Exception("Asserted that there are $number myEntites, but there are actually $actual.");
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.