本文整理汇总了PHP中Drupal\views\Entity\View::set方法的典型用法代码示例。如果您正苦于以下问题:PHP View::set方法的具体用法?PHP View::set怎么用?PHP View::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Entity\View
的用法示例。
在下文中一共展示了View::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initQuery
/**
* Do some common building initialization.
*/
public function initQuery()
{
if (!empty($this->query)) {
$class = get_class($this->query);
if ($class && $class != 'stdClass') {
// return if query is already initialized.
return TRUE;
}
}
// Create and initialize the query object.
$views_data = Views::viewsData()->get($this->storage->get('base_table'));
$this->storage->set('base_field', !empty($views_data['table']['base']['field']) ? $views_data['table']['base']['field'] : '');
if (!empty($views_data['table']['base']['database'])) {
$this->base_database = $views_data['table']['base']['database'];
}
$this->query = $this->display_handler->getPlugin('query');
return TRUE;
}
示例2: testSerialization
/**
* Tests serialization of the ViewUI object.
*/
public function testSerialization()
{
// Set a container so the DependencySerializationTrait has it.
$container = new ContainerBuilder();
\Drupal::setContainer($container);
$storage = new View([], 'view');
$executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')->disableOriginalConstructor()->setConstructorArgs([$storage])->getMock();
$storage->set('executable', $executable);
$view_ui = new ViewUI($storage);
// Make sure the executable is returned before serializing.
$this->assertInstanceOf('Drupal\\views\\ViewExecutable', $view_ui->getExecutable());
$serialized = serialize($view_ui);
// Make sure the ViewExecutable class is not found in the serialized string.
$this->assertSame(strpos($serialized, '"Drupal\\views\\ViewExecutable"'), FALSE);
$unserialized = unserialize($serialized);
$this->assertInstanceOf('Drupal\\views_ui\\ViewUI', $unserialized);
}