本文整理匯總了PHP中Drupal\Core\Entity\EntityListBuilder::setStringTranslation方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityListBuilder::setStringTranslation方法的具體用法?PHP EntityListBuilder::setStringTranslation怎麽用?PHP EntityListBuilder::setStringTranslation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Entity\EntityListBuilder
的用法示例。
在下文中一共展示了EntityListBuilder::setStringTranslation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetOperations
/**
* @covers ::getOperations
*/
public function testGetOperations()
{
$operation_name = $this->randomMachineName();
$operations = array($operation_name => array('title' => $this->randomMachineName()));
$this->moduleHandler->expects($this->once())->method('invokeAll')->with('entity_operation', array($this->role))->will($this->returnValue($operations));
$this->moduleHandler->expects($this->once())->method('alter')->with('entity_operation');
$this->container->set('module_handler', $this->moduleHandler);
$this->role->expects($this->any())->method('access')->will($this->returnValue(AccessResult::allowed()));
$this->role->expects($this->any())->method('hasLinkTemplate')->will($this->returnValue(TRUE));
$url = $this->getMockBuilder('\\Drupal\\Core\\Url')->disableOriginalConstructor()->getMock();
$url->expects($this->any())->method('toArray')->will($this->returnValue(array()));
$this->role->expects($this->any())->method('urlInfo')->will($this->returnValue($url));
$list = new EntityListBuilder($this->entityType, $this->roleStorage, $this->moduleHandler);
$list->setStringTranslation($this->translationManager);
$operations = $list->getOperations($this->role);
$this->assertInternalType('array', $operations);
$this->assertArrayHasKey('edit', $operations);
$this->assertInternalType('array', $operations['edit']);
$this->assertArrayHasKey('title', $operations['edit']);
$this->assertArrayHasKey('delete', $operations);
$this->assertInternalType('array', $operations['delete']);
$this->assertArrayHasKey('title', $operations['delete']);
$this->assertArrayHasKey($operation_name, $operations);
$this->assertInternalType('array', $operations[$operation_name]);
$this->assertArrayHasKey('title', $operations[$operation_name]);
}