David Flores
Linux, Drupal, Symfony, Silex, BackEnd, Seguridad, Python, ...sometimes #Nerd Speaker
david@indava.com
@dmouse
http://bit.ly/guate-how-to-d8
<?php
/**
* @file
* Contains \Drupal\search\Plugin\Block\SearchBlock.
*/
namespace Drupal\search\Plugin\Block;
// ...
/**
* Provides a 'Search form' block.
*
* @Block(
* id = "search_form_block",
* admin_label = @Translation("Search form"),
* category = @Translation("Forms")
* )
*/
class SearchBlock extends BlockBase {
// ...
}
<?php
/**
* @file
* Contains \Drupal\search\Tests\SearchBlockTest.
*/
namespace Drupal\search\Tests;
class SearchBlockTest extends SearchTestBase {
// ...
protected function testSearchFormBlock() {
// Test a normal search via the block form, from the front page.
$terms = array('keys' => 'test');
$this->submitGetForm('', $terms, t('Search'));
$this->assertResponse(200);
$this->assertText('Your search yielded no results');
}
// ...
}
<?php
/**
* @file
* Contains \Drupal\Core\DependencyInjection\ContainerInjectionInterface.
*/
namespace Drupal\Core\DependencyInjection;
interface ContainerInjectionInterface {
public static function create(ContainerInterface $container);
}
$ cd core/modules
$ ls */src/Form -ld
$ ls -d */src/Plugin/* | \
grep -v ".php" | \
awk '{ split($1, folders, "/"); print folders[4]; }' | \
sort | \
uniq
El 50% de los módulos del core tiene un controller
$ ls */src/Controller/ -dl
<?php
/**
* @file
* Contains \Drupal\help\Controller\HelpController.
*/
namespace Drupal\help\Controller;
// ...
class HelpController extends ControllerBase {
// ...
public function helpMain() {
$output = array(
'#attached' => array(
'css' => array(drupal_get_path('module', 'help') . '/css/help.module.css'),
),
'#markup' => '<h2>' . $this->t('Help topics') . '</h2><p>' . $this->t('Help is available ... :') . '</p>' . $this->helpLinksAsList(),
);
return $output;
}
}