chore: fix syntax highlighting languages
This commit is contained in:
parent
14d096a53b
commit
84be97413d
|
@ -32,7 +32,7 @@ database. Then, using [Sequel Pro](http://www.sequelpro.com), I ran the
|
|||
following SQL query to give me a list of Blog posts on my site - showing just
|
||||
their titles and nid values.
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
SELECT title, nid FROM node WHERE TYPE = 'blog' ORDER BY title ASC;
|
||||
```
|
||||
|
||||
|
@ -40,7 +40,7 @@ I made a note of the nid's of the returned nodes, and kept them for later. I
|
|||
then ran a similar query against the term_data table. This returned a list of
|
||||
Taxonomy terms - showing the term's name, and it's unique tid value.
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
SELECT NAME, tid FROM term_data ORDER BY NAME ASC;
|
||||
```
|
||||
|
||||
|
@ -50,7 +50,7 @@ query against the database. I'm using aliases within this query to link the
|
|||
node, term_node and term_data tables. For more information on SQL aliases, take
|
||||
a look at <http://w3schools.com/sql/sql_alias.asp>.
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
SELECT * FROM node n, term_data td, term_node tn WHERE td.tid = 84 AND n.nid = tn.nid AND tn.tid = td.tid;
|
||||
```
|
||||
|
||||
|
@ -65,7 +65,7 @@ To confirm everything, I ran a simple query against an old post. I know that the
|
|||
only taxonomy term associated with this post is 'Personal', which has a tid
|
||||
value of 44.
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
SELECT nid, tid FROM term_node WHERE nid = 216;
|
||||
```
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ when a complete node was displayed.
|
|||
I have previously seen it done this way by adding this into in a node.tpl.php
|
||||
file:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
if ($teaser) {
|
||||
// The teaser output.
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ looks for and attempts to use when displaying a node, and this is where I'll be
|
|||
adding a new suggestion for my teaser-specific template. Using the `debug()`
|
||||
function, I can easily see what's already there.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
array (
|
||||
0 => 'node__article',
|
||||
1 => 'node__343',
|
||||
|
@ -51,7 +51,7 @@ array (
|
|||
|
||||
So, within my theme's template.php file:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
/**
|
||||
* Implementation of hook_preprocess_HOOK().
|
||||
*/
|
||||
|
@ -67,7 +67,7 @@ function mytheme_preprocess_node(&$variables) {
|
|||
|
||||
After adding the new suggestion:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
array (
|
||||
0 => 'node__article',
|
||||
1 => 'node__343',
|
||||
|
|
|
@ -67,7 +67,7 @@ Within the **Builds** section of the item, I added an _Execute Shell_ step,
|
|||
where I could enter a command to execute. Here, I pasted a modified version of
|
||||
the original publish.sh script.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
set -uex
|
||||
|
@ -94,7 +94,7 @@ or greater than the time of the build.
|
|||
|
||||
The YAML front matter:
|
||||
|
||||
```language-yaml
|
||||
```yaml
|
||||
---
|
||||
...
|
||||
talks:
|
||||
|
@ -105,7 +105,7 @@ talks:
|
|||
|
||||
The Twig layout:
|
||||
|
||||
```language-twig
|
||||
```twig
|
||||
|
||||
{% for talk in talks|reverse if talk.date >= now %}
|
||||
{# Upcoming talks #}
|
||||
|
@ -155,7 +155,7 @@ script.
|
|||
|
||||
### Updating Composer
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
if [ -f composer.json ]; then
|
||||
/usr/local/bin/composer install
|
||||
fi
|
||||
|
@ -167,7 +167,7 @@ composer.json exists.
|
|||
|
||||
### Updating Sculpin Dependencies
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
if [ -f sculpin.json ]; then
|
||||
sculpin install
|
||||
fi
|
||||
|
@ -178,7 +178,7 @@ that the required custom bundles and dependencies are installed.
|
|||
|
||||
### Managing Redirects
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
if [ -f scripts/redirects.php ]; then
|
||||
/usr/bin/php scripts/redirects.php
|
||||
fi
|
||||
|
|
|
@ -24,7 +24,7 @@ using a [Twig][2] template.
|
|||
|
||||
For example:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
# test.php
|
||||
|
||||
require __DIR__ '/vendor/autoload.php';
|
||||
|
@ -64,7 +64,7 @@ and replace them with the `boolean_string` filter.
|
|||
Before:
|
||||
|
||||
<div v-pre markdown="1">
|
||||
```language-twig
|
||||
```twig
|
||||
{{ filter.isArchive ? 'true' : 'false' }}
|
||||
```
|
||||
</div>
|
||||
|
@ -72,7 +72,7 @@ Before:
|
|||
After:
|
||||
|
||||
<div v-pre markdown="1">
|
||||
```language-twig
|
||||
```twig
|
||||
{{ filter.isArchive|boolean_string }}
|
||||
```
|
||||
</div>
|
||||
|
@ -80,7 +80,7 @@ After:
|
|||
This can then be used to generate output like this, whereas having blank values
|
||||
would have resulted in errors when importing to Gmail.
|
||||
|
||||
```language-xml
|
||||
```xml
|
||||
<apps:property name='shouldArchive' value='true'/>
|
||||
```
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ I see this regularly when working on Drupal sites when someone wants to check
|
|||
whether the current user is logged in to Drupal (authenticated) or not
|
||||
(anonymous).
|
||||
|
||||
```language-php
|
||||
```php
|
||||
global $user;
|
||||
if ($user->uid) {
|
||||
// The user is logged in.
|
||||
|
@ -23,7 +23,7 @@ if ($user->uid) {
|
|||
|
||||
or
|
||||
|
||||
```language-php
|
||||
```php
|
||||
global $user;
|
||||
if (!$user->uid) {
|
||||
// The user is not logged in.
|
||||
|
@ -34,7 +34,7 @@ The better way to do this is to use the
|
|||
[user_is_logged_in()](http://api.drupal.org/api/drupal/modules!user!user.module/function/user_is_logged_in/7)
|
||||
function.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
if (user_is_logged_in()) {
|
||||
// Do something.
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ load the global variable.
|
|||
A great use case for this is within a `hook_menu()` implementation within a
|
||||
custom module.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
|
|
|
@ -11,12 +11,12 @@ How to checkout a specific revision from a SVN (Subversion) repository.
|
|||
|
||||
If you're checking out the repository for the first time:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ svn checkout -r 1234 url://repository/path
|
||||
```
|
||||
|
||||
If you already have the repository checked out:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ svn up -r 1234
|
||||
```
|
||||
|
|
|
@ -16,7 +16,7 @@ configuration until after I created the form components. I added 'Name',
|
|||
'Email', 'Subject' and 'Message' fields, as well as a 'Category' select list.
|
||||
Below 'Options', I entered each of my desired options in the following format:
|
||||
|
||||
```language-ini
|
||||
```ini
|
||||
Email address|Visible name
|
||||
```
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ have one) or the standard settings.php file.
|
|||
The first thing that we need to do is to enable rerouting. Without doing this,
|
||||
nothing will happen.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$conf['reroute_email_enable'] = TRUE;
|
||||
```
|
||||
|
||||
|
@ -39,14 +39,14 @@ The next option is to whether to show rerouting description in mail body. I
|
|||
usually have this enabled. Set this to TRUE or FALSE depending on your
|
||||
preference.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$conf['reroute_email_enable_message'] = TRUE;
|
||||
```
|
||||
|
||||
The last setting is the email address to use. If you're entering a single
|
||||
address, you can add it as a simple string.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$conf['reroute_email_address'] = 'person1@example.com';
|
||||
```
|
||||
|
||||
|
@ -57,7 +57,7 @@ If you want to add multiple addresses, these should be added in a
|
|||
semicolon-delimited list. Whilst you could add these also as a string, I prefer
|
||||
to use an array of addresses and the `implode()` function.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$conf['reroute_email_address'] = implode(';', array(
|
||||
'person1@example.com',
|
||||
'person2@example.com',
|
||||
|
|
|
@ -39,7 +39,7 @@ have a list of all the galleries on my site which are published, and what
|
|||
they're unique node ID values are. To do this, I opened Sequel Pro and entered
|
||||
the following code:
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
SELECT title
|
||||
AS title, nid
|
||||
AS gallery_idFROM node
|
||||
|
@ -55,7 +55,7 @@ For example, using [aliasing](http://www.w3schools.com/sql/sql_alias.asp) within
|
|||
my SQL statement, I can retrieve a list of all the published photos within the
|
||||
'British Squad 2008' gallery by using the following code:
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
SELECT n.title, n.nid, p.field_gallery_nid
|
||||
FROM node n, content_type_photo p
|
||||
WHERE p.field_gallery_nid = 105
|
||||
|
@ -66,7 +66,7 @@ AND n.nid = p.nid;
|
|||
I can easily change this to count the number of published nodes by changing the
|
||||
first line of the query to read SELECT COUNT(\*).
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
SELECT COUNT(*)
|
||||
FROM node n, content_type_photo p
|
||||
WHERE p.field_gallery_nid = 105
|
||||
|
@ -80,7 +80,7 @@ to each gallery by creating a custom node-gallery.tpl.php file within my theme.
|
|||
I can then use the following PHP code to retrieve the node ID for that specific
|
||||
gallery:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
$selected_gallery = db_result(db_query("
|
||||
SELECT nid
|
||||
|
@ -94,7 +94,7 @@ AND title = '$title'
|
|||
I can then use this variable as part of my next query to count the number of
|
||||
photos within that gallery, similar to what I did earlier.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
$gallery_total = db_result(db_query("
|
||||
SELECT COUNT(*)
|
||||
|
@ -109,7 +109,7 @@ album. This was done by using a similar query that also sorted the results in a
|
|||
descending order, and limited it to one result - effectively only returning the
|
||||
created date for the newest photo.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
$latest_photo = db_result(db_query("
|
||||
SELECT n.created
|
||||
|
@ -124,7 +124,7 @@ ORDER BY n.created DESC LIMIT 1
|
|||
This was all then added into a 'print' statement which displayed it into the
|
||||
page.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
if ($selected_gallery_total != 0) {
|
||||
$output = '<i>There are currently ' . $selected_gallery_total . ' photos in this gallery.';
|
||||
|
@ -140,7 +140,7 @@ You will notice that the returned date value for the latest photo added is
|
|||
displaying the UNIX timestamp instead of in a more readable format. This can be
|
||||
changed by altering the 'print' statement to include a PHP 'date' function:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
if ($selected_gallery_total != 0) {
|
||||
$output = '<i>There are currently ' . $selected_gallery_total . ' photos in this gallery.';
|
||||
|
|
|
@ -19,7 +19,7 @@ before, and create something different that also displays the created and
|
|||
modified dates. Picking the node ID of the required gallery, I used the
|
||||
following SQL query to display a list of photos.
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
SELECT n.title, n.nid, n.created, n.changed, p.field_gallery_nid
|
||||
FROM node n, content_type_photo pWHERE n.type = 'photo'
|
||||
AND p.field_gallery_nid = 103AND n.nid = p.nid
|
||||
|
@ -36,7 +36,7 @@ gallery to the same time.
|
|||
The result that I'm given is '1217149200'. I can now use an UPDATE statement
|
||||
within another SQL query to update the created and modified dates.
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
UPDATE node
|
||||
INNER JOIN content_type_photo
|
||||
ON node.nid = content_type_photo.nid
|
||||
|
|
|
@ -14,7 +14,7 @@ that I'd include it in
|
|||
[Part 3](/blog/create-better-photo-gallery-drupal-part-3/ 'Create a Better Photo Gallery in Drupal - Part 3'),
|
||||
but I forgot). So, here it is:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Queries the database and returns a list of nids of published galleries.
|
||||
|
|
|
@ -22,14 +22,14 @@ the heading information from the original View. I can now use the function
|
|||
called 'views_embed_view' to embed my taxonomy display onto the display. The
|
||||
views_embed_view function is as follows:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php views_embed_view('my_view', 'block_1', $arg1, $arg2); ?>
|
||||
```
|
||||
|
||||
So, to display the galleries that are assigned the taxonomy of 'tournaments', I
|
||||
can use the following:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php print views_embed_view('photo_gallery', 'page_2', 'tournaments'); ?>
|
||||
```
|
||||
|
||||
|
@ -38,7 +38,7 @@ generate the same code for each taxonomy term. It dynamically retrieves the
|
|||
relevant taxonomy terms from the database, and uses each name as the argument
|
||||
for the view.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
$terms = db_query("SELECT * FROM {term_data} WHERE vid = 1");
|
||||
while ($term = db_fetch_array($terms)) {
|
||||
|
|
|
@ -21,7 +21,7 @@ Tools and [LESS](http://drupal.org/project/less 'LESS module on drupal.org')
|
|||
modules, and then to enable both modules. I'm doing this using Drush, but you
|
||||
can of course do this via the admin interface at admin/modules.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush dl less omega omega_tools;
|
||||
$ drush en -y less omega_tools
|
||||
```
|
||||
|
@ -30,14 +30,14 @@ With the Omega Tools module enabled I get the drush omega-subtheme command that
|
|||
creates my Omega subtheme programatically. Using this command, I'm creating a
|
||||
new subtheme, enabling it and setting it as the default theme on my site.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush omega-subtheme "Oliver Davies" --machine_name="oliverdavies" --enable --set-default
|
||||
```
|
||||
|
||||
By default, four stylesheets are created within the subtheme's css directory.
|
||||
The first thing that I'm going to do is rename `global.css` to `global.less`.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ mv css/global.css css/global.less
|
||||
```
|
||||
|
||||
|
@ -48,7 +48,7 @@ then `Ctrl+R` to replace, entering `global.css` as the search phrase, and then
|
|||
oliverdavies.info, I need to clear Drupal's caches for the changes to be
|
||||
applied.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush cc all
|
||||
```
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ page.
|
|||
I added the following code into my About page, as described in the Fancy Slide
|
||||
readme.txt file - the number representing the ID of the slideshow.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php print theme('fancy_slide', 1); ?>
|
||||
```
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ sub-theme of [Zen](https://drupal.org/project/zen).
|
|||
First, download the [Zen](https://drupal.org/project/zen 'The Zen theme') theme
|
||||
if you haven't already done so.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush dl zen
|
||||
```
|
||||
|
||||
This will now enable you to use the "drush zen" command.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush zen "Oliver Davies" oliverdavies --description="A Zen sub-theme for oliverdavies.co.uk" --without-rtl
|
||||
```
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ best solution I think is to use table prefixes and create a different domain
|
|||
table per environment. With a live, staging and local domains, the tables would
|
||||
be named as follows:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
live_domain
|
||||
local_domain
|
||||
staging_domain
|
||||
|
@ -33,7 +33,7 @@ Within each site's settings.php file, define the prefix for the domain table
|
|||
within the databases array so that each site is looking at the correct table for
|
||||
its environment.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$databases['default']['default'] = array(
|
||||
'driver' => 'mysql',
|
||||
'database' => 'foobar',
|
||||
|
|
|
@ -40,7 +40,7 @@ itself, along with it's descriptive text. To view the existing tokens and types,
|
|||
use `dpm(token_get_info());`, assuming that you have the
|
||||
[Devel module](http://drupal.org/project/devel) installed.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
/**
|
||||
* Implements hook_token_info().
|
||||
*/
|
||||
|
@ -66,7 +66,7 @@ Now that the Token module is aware of our new token, we now need to determine
|
|||
what the token is replaced with. This is done using `hook_tokens()`. Here is the
|
||||
basic code needed for an implementation:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
/**
|
||||
* Implements hook_tokens().
|
||||
*/
|
||||
|
@ -88,7 +88,7 @@ available tokens using a `switch()`. For each token, you can perform some logic
|
|||
to work out the replacement text and then add it into the replacements array
|
||||
using `$replacements[$original] = $new;`.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
/**
|
||||
* Implements hook_tokens().
|
||||
*/
|
||||
|
@ -123,7 +123,7 @@ function foo_tokens($type, $tokens, array $data = array(), array $options = arra
|
|||
|
||||
An example from Copyright Block module:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
/**
|
||||
* Implements hook_tokens().
|
||||
*/
|
||||
|
@ -153,7 +153,7 @@ With everything defined, all that we now need to do is pass some text through
|
|||
the `token_replace()` function to replace it with the values defined within
|
||||
`hook_token()`.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$a = t('Something');
|
||||
// This would use any token type - node, user etc.
|
||||
$b = token_replace($a);
|
||||
|
|
|
@ -13,7 +13,7 @@ tags:
|
|||
For reference, this is the code needed to display a menu in a Drupal 7 template
|
||||
file, including the navigation ARIA role.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$menu_name = 'menu-footer-menu';
|
||||
$menu_id = 'footer-menu';
|
||||
print theme('links', array(
|
||||
|
|
|
@ -18,7 +18,7 @@ Here's how to do it.
|
|||
|
||||
For example (with some slight modifications):
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
oliver@oliver-mbp:~/Development/drupal(master) $
|
||||
oliver@oliver-mbp:~/Development/a11y_checklist(7.x-1.0) $
|
||||
```
|
||||
|
@ -27,13 +27,13 @@ Here's how to do it.
|
|||
|
||||
To begin with, create a new file to contain the functions,
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
vim ~/.bash/git-prompt
|
||||
```
|
||||
|
||||
Paste the following code into the file, and save it.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
parse_git_branch () {
|
||||
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ parse_git_branch_or_tag() {
|
|||
|
||||
Edit your `.bashrc` or `.bash_profile` file to override the PS1 value.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
vim ~/.bashrc
|
||||
```
|
||||
|
||||
Add the following code at the bottom of the file, and save it.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
source ~/.bash/git-prompt
|
||||
PS1="\u@\h:\w\$(parse_git_branch_or_tag) $ "
|
||||
```
|
||||
|
|
|
@ -19,7 +19,7 @@ formatted with commas etc - like where I've used it within the
|
|||
[Gold Event listing](http://www.horseandcountry.tv/events/paid) on the Horse &
|
||||
Country TV website.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$page_id = "143394365692197";
|
||||
$xml = @simplexml_load_file("http://api.facebook.com/restserver.php?method=facebook.fql.query&query=SELECT%20fan_count%20FROM%20page%20WHERE%20page_id=".$page_id."") or die ("a lot");
|
||||
$fans = $xml->page->fan_count;
|
||||
|
|
|
@ -21,7 +21,7 @@ process/page.inc.
|
|||
The first step is to use the default mytheme_process() and mytheme_preprocess()
|
||||
functions to utilise my custom function. So within my template.php file:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ function mytheme_process(&$variables, $hook) {
|
|||
|
||||
Now, to write the `mytheme_invoke()` function:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ to write a .php script and bootstrap Drupal to gain access to functions like
|
|||
To bootstrap Drupal, you would need to add some additional lines of code to the
|
||||
stop of your script. Here is an alternative way.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
|
||||
// Bootstrap Drupal.
|
||||
|
@ -36,14 +36,14 @@ http://example.com/foo.php to execute it. This is where the "drush php-script"
|
|||
command (or "drush scr" for short) is useful, and can be used to execute the
|
||||
script from the command line.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush scr foo.php
|
||||
```
|
||||
|
||||
It also means that I no longer need to manually bootstrap Drupal, so my script
|
||||
is much cleaner.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
// Just do stuff.
|
||||
$node = node_load(1);
|
||||
```
|
||||
|
@ -56,14 +56,14 @@ can now run the following command to go up one level, into the scripts directory
|
|||
and then execute the script. Note that you do not need to include the file
|
||||
extension.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush scr ../scripts/foo
|
||||
```
|
||||
|
||||
Or, if you're using
|
||||
[Drush aliases](http://deeson-online.co.uk/labs/drupal-drush-aliases-and-how-use-them 'Drupal, Drush aliases, and how to use them'):
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush @mysite.local scr foo
|
||||
```
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ need to download that as well.
|
|||
By declarding the core version of Drupal, such as "drupal-6", Drush will
|
||||
download that instead.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush dl drupal-6
|
||||
```
|
||||
|
||||
|
@ -34,20 +34,20 @@ This downloads the most recent stable version of Drupal 6. If you don't want
|
|||
that, you can add the --select and additionally the --all options to be
|
||||
presented with an entire list to chose from.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush dl drupal-6 --select
|
||||
$ drush dl drupal-6 --select --all
|
||||
```
|
||||
|
||||
If you want the most recent development version, just type:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush dl drupal-6.x
|
||||
```
|
||||
|
||||
The same can be done for other core versions of Drupal, from Drupal 5 upwards.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
# This will download Drupal 5
|
||||
$ drush dl drupal-5
|
||||
# This will download Drupal 8
|
||||
|
|
|
@ -43,7 +43,7 @@ the site went live).
|
|||
|
||||
This I believe is the Drupal code where the error was being triggered:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
// modules/contrib/commerce_stripe/src/Plugin/Commerce/PaymentGateway/Stripe.php
|
||||
|
||||
public function createPayment(PaymentInterface $payment, $capture = TRUE) {
|
||||
|
@ -70,7 +70,7 @@ public function createPayment(PaymentInterface $payment, $capture = TRUE) {
|
|||
|
||||
I can also see in the Stripe library where the original error is generated.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
private static function _specificAPIError($rbody, $rcode, $rheaders, $resp, $errorData)
|
||||
{
|
||||
$msg = isset($errorData['message']) ? $errorData['message'] : null;
|
||||
|
|
|
@ -16,7 +16,7 @@ necessary command every time.
|
|||
For example, here is the command provided to clone Drupal’s
|
||||
[Override Node Options module](https://www.drupal.org/project/override_node_options):
|
||||
|
||||
```plain
|
||||
```
|
||||
git clone --branch 8.x-2.x https://git.drupal.org/project/override_node_options.git
|
||||
```
|
||||
|
||||
|
@ -51,7 +51,7 @@ patches to.
|
|||
|
||||
Again, here is the provided command to clone the Override Node Options module:
|
||||
|
||||
```plain
|
||||
```
|
||||
git clone --branch 8.x-2.x https://git.drupal.org/project/override_node_options.git
|
||||
```
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ watch session was also ending the script process.
|
|||
|
||||
### composer.json
|
||||
|
||||
```language-json
|
||||
```json
|
||||
"scripts": {
|
||||
"clean": "rm -rf output_*/",
|
||||
"dev": "sculpin generate --clean --no-interaction --server --watch",
|
||||
|
@ -49,7 +49,7 @@ Run with `composer run <name>`, e.g. `composer run dev`.
|
|||
|
||||
### package.json
|
||||
|
||||
```language-json
|
||||
```json
|
||||
"scripts": {
|
||||
"init": "yarn && bower install",
|
||||
"dev": "gulp watch",
|
||||
|
|
|
@ -23,7 +23,7 @@ The first thing that I needed to do to render the form was to load an empty
|
|||
instance of the entityform using `entityform_empty_load()`. In this example,
|
||||
`newsletter` is the name of my form type.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$form = entityform_empty_load('newsletter');
|
||||
```
|
||||
|
||||
|
@ -38,7 +38,7 @@ As this function is within the `entityform.admin.inc` file and not autoloaded by
|
|||
Drupal, I needed to include it using `module_load_include()` so that the
|
||||
function was available.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
module_load_include('inc', 'entityform', 'entityform.admin');
|
||||
|
||||
$output = entityform_form_wrapper($form, 'submit', 'embedded'),
|
||||
|
|
|
@ -29,7 +29,7 @@ lot of them would fail where they would pass when run within Drupal VM.
|
|||
|
||||
Here’s an excerpt from my `docker-compose.yml` file:
|
||||
|
||||
```language-yaml
|
||||
```yaml
|
||||
services:
|
||||
php:
|
||||
image: wodby/drupal-php:5.6
|
||||
|
@ -53,7 +53,7 @@ across both and the Nginx backend is set to use the `php` container.
|
|||
|
||||
This is the command that I was using to run the tests:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ docker-compose run --rm \
|
||||
-w /var/www/html/web \
|
||||
php \
|
||||
|
@ -71,7 +71,7 @@ the `--rm` option.
|
|||
This resulted in 60 of the 112 tests failing, whereas they all passed when run
|
||||
within a Drupal VM instance.
|
||||
|
||||
```language-markup
|
||||
```
|
||||
Test summary
|
||||
------------
|
||||
|
||||
|
@ -95,7 +95,7 @@ site, I got this error message:
|
|||
Whereas `curl http://nginx` returns the HTML for the page, so included it with
|
||||
the `--url` option to `run-tests.sh`, and this resulted in my tests all passing.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ docker-compose run --rm \
|
||||
-w /var/www/html/web \
|
||||
php \
|
||||
|
@ -105,7 +105,7 @@ $ docker-compose run --rm \
|
|||
--class OverrideNodeOptionsTestCase
|
||||
```
|
||||
|
||||
```language-markup
|
||||
```
|
||||
Test summary
|
||||
------------
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ message.
|
|||
|
||||
For example:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
--author="opdavies <opdavies@381388.no-reply.drupal.org>"
|
||||
```
|
||||
|
||||
|
@ -61,7 +61,7 @@ From the [manual page](http://git-scm.com/docs/git-format-patch):
|
|||
Here is a section of a patch that I created for the
|
||||
[Metatag module](http://drupal.org/project/metatag) using `git format-patch`:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
From 80c8fa14de7f4a83c2e70367aab0aedcadf4f3b0 Mon Sep 17 00:00:00 2001
|
||||
From: Oliver Davies <oliver@oliverdavies.co.uk>
|
||||
Subject: [PATCH] Exclude comment entities when checking if this is the page,
|
||||
|
@ -116,14 +116,14 @@ best command to do this with is the `git am` command.
|
|||
|
||||
For example, within your repository, run:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ git am /path/to/file
|
||||
$ git am ~/Code/metatag-comment-fragment-conflict-2265447-4.patch
|
||||
```
|
||||
|
||||
You should end up with some output similar to the following:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
Applying: #2272799 Added supporters section
|
||||
Applying: #2272799 Added navigation tabs
|
||||
Applying: #2272799 Fixed indentation
|
||||
|
|
|
@ -19,13 +19,13 @@ First, I need to download the
|
|||
make my module dependent on date_popup by adding the following line into my
|
||||
module's .info file.
|
||||
|
||||
```language-ini
|
||||
```ini
|
||||
dependencies[] = date_popup
|
||||
```
|
||||
|
||||
Within my form builder function:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$form['date'] = array(
|
||||
'#title' => t('Arrival date'),
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ original user.pages.inc file. Within the duplicate file, I made the same changes
|
|||
to the function that I did in earlier code, and saved the changes. Now, within
|
||||
my Terminal, I can navigate to Drupal's root directory and create the patch.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
diff -rup modules/user/user.pages.inc modules/user/user.pages2.inc > /Users/oliver/Desktop/different_messages_for_blocked_users.patch
|
||||
```
|
||||
|
||||
|
@ -32,13 +32,13 @@ specified patch file.
|
|||
To apply the patch to my Drupal installation, I go back to Terminal and run the
|
||||
following code:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
patch -p0 < /Users/oliver/Desktop/different_messages_for_blocked_users.patch
|
||||
```
|
||||
|
||||
If, for some reason, I need to reverse the patch, I can run this code:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
patch -p0 -R < /Users/oliver/Desktop/different_messages_for_blocked_users.patch
|
||||
```
|
||||
|
||||
|
|
|
@ -20,14 +20,14 @@ already installed.
|
|||
Firstly, I'm going to ensure that all of my installed packages are up to date,
|
||||
and install any available updates.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ sudo apt-get update
|
||||
```
|
||||
|
||||
Now, I need to download the subversion, subversion-tools and libapache2
|
||||
packages.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ sudo apt-get install subversion subversion-tools libapache2-svn
|
||||
```
|
||||
|
||||
|
@ -39,7 +39,7 @@ Now, I need to create the directory where my repositories are going to sit. I've
|
|||
chosen this directory as I know that it's one that is accessible to my managed
|
||||
backup service.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ sudo mkdir /home/svn
|
||||
```
|
||||
|
||||
|
@ -48,7 +48,7 @@ $ sudo mkdir /home/svn
|
|||
First, I'll create a new folder in which I'll create my test project, and then
|
||||
I'll create a repository for it.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ sudo mkdir ~/test
|
||||
$ sudo svnadmin create /home/svn/test -m 'initial project structure'
|
||||
```
|
||||
|
@ -57,14 +57,14 @@ This will create a new repository containing the base file structure.
|
|||
|
||||
## Adding files into the test project
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ cd ~/test
|
||||
$ mkdir trunk tags branches
|
||||
```
|
||||
|
||||
I can now import these new directories into the test repository.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ sudo svn import ~/test file:///home/svn/test -m 'Initial project directories'
|
||||
```
|
||||
|
||||
|
@ -75,7 +75,7 @@ needs to be owned by the same user and group that Apache runs as. In Ubuntu,
|
|||
this is usually www-data. To change the owner of a directory, use the chown
|
||||
command.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ sudo chown -R www-data:www-data /home/svn
|
||||
```
|
||||
|
||||
|
@ -84,13 +84,13 @@ $ sudo chown -R www-data:www-data /home/svn
|
|||
The first thing that I need to do is enable the dav_svn Apache module, using the
|
||||
a2enmod command.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ sudo a2enmod dav_svn
|
||||
```
|
||||
|
||||
With this enabled, now I need to modify the Apache configuration file.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ cd /etc/apache2
|
||||
$ sudo nano apache2.conf
|
||||
```
|
||||
|
@ -98,7 +98,7 @@ $ sudo nano apache2.conf
|
|||
At the bottom of the file, add the following lines, and then save the file by
|
||||
pressing Ctrl+X.
|
||||
|
||||
```language-apacheconf
|
||||
```
|
||||
<Location "/svn">
|
||||
DAV svn
|
||||
SVNParentPath /home/svn
|
||||
|
@ -107,7 +107,7 @@ pressing Ctrl+X.
|
|||
|
||||
With this saved, restart the Apache service for the changes to be applied.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
sudo service apache2 restart
|
||||
```
|
||||
|
||||
|
@ -125,7 +125,7 @@ password before viewing or performing any actions with the repository.
|
|||
|
||||
Re-open apache2.conf, and replace the SVN Location information with this:
|
||||
|
||||
```language-apacheconf
|
||||
```
|
||||
<Location "/svn">
|
||||
DAV svn
|
||||
SVNParentPath /home/svn
|
||||
|
@ -138,7 +138,7 @@ Re-open apache2.conf, and replace the SVN Location information with this:
|
|||
|
||||
Now I need to create the password file.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ htpasswd -cm /etc/svn-auth oliver
|
||||
```
|
||||
|
||||
|
@ -152,7 +152,7 @@ For example, now want to checkout the files within my repository into a new
|
|||
directory called 'test2' within my home directory. Firstly, I need to create the
|
||||
new directory, and then I can issue the checkout command.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ cd ~
|
||||
$ mkdir test2
|
||||
$ svn checkout http://127.0.0.1/svn/test/trunk test2
|
||||
|
@ -168,7 +168,7 @@ Now you can start adding files into the directory. Once you've created your
|
|||
files, perform a svn add command, passing in individual filenames as further
|
||||
arguments.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ svn add index.php
|
||||
$ svn add *
|
||||
```
|
||||
|
|
|
@ -12,7 +12,7 @@ Within the [Docksal documentation for Drupal settings][0], the example database
|
|||
settings include hard-coded credentials to connect to the Drupal database. For
|
||||
example, within a `settings.php` file, you could add this:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$databases['default']['default'] = [
|
||||
'driver' => 'mysql',
|
||||
'host' => 'db',
|
||||
|
@ -76,7 +76,7 @@ If you see this, the environment variables aren’t being passed into Docksal’
|
|||
`.docksal/docksal.yml` and add `MYSQL_DATABASE`, `MYSQL_PASSWORD` and
|
||||
`MYSQL_USER` to the `environment` section of the `cli` service.
|
||||
|
||||
```language-yml
|
||||
```yaml
|
||||
version: '2.1'
|
||||
services:
|
||||
cli:
|
||||
|
|
|
@ -16,7 +16,7 @@ Using a file structure similar to this, organise your font files into
|
|||
directories, using the the font name for both the directory name and for the
|
||||
file names.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
.
|
||||
├── FuturaBold
|
||||
│ ├── FuturaBold.eot
|
||||
|
@ -44,7 +44,7 @@ Within your SASS file, start an `@each` loop, listing the names of the fonts. In
|
|||
the same way as PHP's `foreach` loop, each font name will get looped through
|
||||
using the `$family` variable and then compiled into CSS.
|
||||
|
||||
```language-scss
|
||||
```scss
|
||||
@each $family in FuturaBook, FuturaBold, FuturaBoldItalic, FuturaItalic {
|
||||
@font-face {
|
||||
font-family: #{$family};
|
||||
|
@ -62,6 +62,6 @@ using the `$family` variable and then compiled into CSS.
|
|||
When the CSS has been compiled, you can then use in your CSS in the standard
|
||||
way.
|
||||
|
||||
```language-scss
|
||||
```scss
|
||||
font-family: "FuturaBook";
|
||||
```
|
||||
|
|
|
@ -17,7 +17,7 @@ defined within settings.php (this is also best practice on all Drupal sites).
|
|||
The way that was recommended was by using a `switch()` function based on
|
||||
Pantheon's environment variable. For example:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
switch ($_SERVER['PANTHEON_ENVIRONMENT']) {
|
||||
case 'dev':
|
||||
// Development environment.
|
||||
|
@ -48,7 +48,7 @@ file.
|
|||
|
||||
To do this, add the following code to the bottom of settings.php:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
if (isset($_SERVER['PANTHEON_ENVIRONMENT'])) {
|
||||
if ($_SERVER['PANTHEON_ENVIRONMENT'] != 'live') {
|
||||
// You can still add things here, for example to apply to all sites apart
|
||||
|
@ -79,7 +79,7 @@ Within the sites/default directory, I also include an example file
|
|||
(example.settings.env.php) for reference. This is duplicated, renamed and
|
||||
populated accordingly.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ credentials and API keys safe.
|
|||
|
||||
At the bottom of settings.php, add the following code:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$local_settings = __DIR__ . '/settings.local.php';
|
||||
if (file_exists($local_settings)) {
|
||||
include $local_settings;
|
||||
|
@ -42,14 +42,14 @@ won't show up as a file available to be committed. There are two ways to fix
|
|||
this. The first is to use the `--force` option when adding the file which
|
||||
overrides the ignore file:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
git add --force sites/default/settings.php
|
||||
```
|
||||
|
||||
The other option is to update the .gitignore file itself so that settings.php is
|
||||
no longer ignored. An updated .gitignore file could look like:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
# Ignore configuration files that may contain sensitive information.
|
||||
sites/*/settings.local*.php
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ changes._
|
|||
The library can be downloaded directly from GitHub, and should be placed within
|
||||
you _sites/all/libraries/nomensa_amp_ directory.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
drush dl libraries nomensa_amp
|
||||
git clone https://github.com/nomensa/Accessible-Media-Player sites/all/libraries/nomensa_amp
|
||||
cd sites/all/libraries/nomensa_amp
|
||||
|
@ -44,13 +44,13 @@ Within your content add links to your videos. For example:
|
|||
|
||||
### YouTube
|
||||
|
||||
```language-html
|
||||
```html
|
||||
<a href="http://www.youtube.com/watch?v=Zi31YMGmQC4">Checking colour contrast</a>
|
||||
```
|
||||
|
||||
### Vimeo
|
||||
|
||||
```language-html
|
||||
```html
|
||||
<a href="http://vimeo.com/33729937">Screen readers are strange, when you're a stranger by Leonie Watson</a>
|
||||
```
|
||||
|
||||
|
@ -66,7 +66,7 @@ captions file:
|
|||
|
||||
For example:
|
||||
|
||||
```language-html
|
||||
```html
|
||||
<a href="http://www.youtube.com/watch?v=Zi31YMGmQC4">Checking colour contrast</a> <a class="captions" href="http://oliverdavies.co.uk/sites/default/files/checking-colour-contrast-captions.xml">Captions for Checking Colour Contrast</a>
|
||||
```
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ foreach ($client->stream($responses) as $response => $chunk) {
|
|||
|
||||
#### FrameworkBundle/Autowiring
|
||||
|
||||
```yml
|
||||
```yaml
|
||||
framework:
|
||||
http_client:
|
||||
max_host_connections: 4
|
||||
|
|
|
@ -41,7 +41,7 @@ file.
|
|||
You can define a simple dependency for your module by adding a line this this to
|
||||
your project's .info file:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
dependencies[] = views
|
||||
```
|
||||
|
||||
|
@ -55,13 +55,13 @@ In the previous example, our module would enable if _any_ version of Views was
|
|||
enabled, but we need to specify a specific version. We can do this by including
|
||||
version numbers within the dependencies field in the following format:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
dependencies[] = modulename (major.minor)
|
||||
```
|
||||
|
||||
This can be a for a specific module release or a branch name:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
dependencies[] = modulename (1.0)
|
||||
dependencies[] = modulename (1.x)
|
||||
```
|
||||
|
@ -79,7 +79,7 @@ In the original scenario, we want to specify that the module can only be enabled
|
|||
on Drupal core 7.36 or later. To do this, we can use the "greater than or equal
|
||||
to" option.
|
||||
|
||||
```language-ini
|
||||
```ini
|
||||
dependencies[] = system (>=7.36)
|
||||
```
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ of a file etc.
|
|||
|
||||
These can be changed by going to Preferences > Settings - User.
|
||||
|
||||
```language-json
|
||||
```json
|
||||
{
|
||||
"color_scheme": "Packages/Theme - Aqua/Color Schemes/Tomorrow Night Aqua.tmTheme",
|
||||
"default_line_ending": "unix",
|
||||
|
@ -87,7 +87,7 @@ These can be changed by going to Preferences > Settings - User.
|
|||
|
||||
These can be changed by going to Preferences > Key Bindings - User.
|
||||
|
||||
```language-json
|
||||
```json
|
||||
[
|
||||
{ "keys": ["alt+s"], "command": "toggle_side_bar" },
|
||||
{ "keys": ["alt+r"], "command": "reindent" }
|
||||
|
|
|
@ -10,7 +10,7 @@ This is an example of how my Nginx configuration looked to redirect from an old
|
|||
domain to a new one, and also to redirect from the root `example.com` domain to
|
||||
the canonical `www` subdomain.
|
||||
|
||||
```language-nginx
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
|
@ -33,13 +33,13 @@ This was fixed by making a small change to my `return` statement.
|
|||
|
||||
Before:
|
||||
|
||||
```language-nginx
|
||||
```nginx
|
||||
return 301 https://www.example.com$uri;
|
||||
```
|
||||
|
||||
After:
|
||||
|
||||
```language-nginx
|
||||
```nginx
|
||||
return 301 https://www.example.com$uri$is_args$args;
|
||||
```
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ for users in Drupal 8. In this case, a [NullUser][4] is an extension of Drupal
|
|||
for a non-existent User. Though, through inheritance, the `id`, `getRoles` and
|
||||
`hasPermission` methods are overridden to return relevant values.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
use Drupal\Core\Session\AnonymousUserSession;
|
||||
|
||||
class NullUser extends AnonymousUserSession {
|
||||
|
@ -111,7 +111,7 @@ user is found from the `getFirst()` method, a `NullUser` is returned. Whilst I
|
|||
could alternatively have returned `NULL` or `FALSE`, we then would need to check
|
||||
if the returned value was an object or not before calling methods on it.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$system_user = $this->systemUserManager->getFirst(); // Returns NULL or FALSE.
|
||||
|
||||
// Need to check if a user was returned or not.
|
||||
|
@ -129,7 +129,7 @@ has the same methods and properties as a regular user, there is no need to do
|
|||
the additional check as you will always receive a relevant object, and the
|
||||
expected methods will always be present.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$system_user = $this->systemUserManager->getFirst(); // Returns a NullUser.
|
||||
|
||||
if ($system_user->isActive()) {
|
||||
|
|
|
@ -13,7 +13,7 @@ How to open Sublime Text from the command line.
|
|||
Paste the following code into the Mac OS X Terminal, assuming that you've
|
||||
installed Sublime Text 2 into the /Applications folder.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/sublime
|
||||
```
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ running and could therefore have security implications.
|
|||
Rather than delete these files or change the file permissions manually for each
|
||||
file, I can add the following lines into my VirtualHost configuration.
|
||||
|
||||
```language-apacheconf
|
||||
```
|
||||
<Files ~ "\.txt$">
|
||||
Order deny,allow
|
||||
Deny from all
|
||||
|
|
|
@ -47,7 +47,7 @@ perform a merge.
|
|||
To simplify this, I’ve added a new [publish.sh script][3] into my repository to
|
||||
automate the sites. This is how it currently looks:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SITE_ENV="prod"
|
||||
|
|
|
@ -14,7 +14,7 @@ After reading numerous blog posts about how to install
|
|||
|
||||
Just paste the following lines into your Terminal:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ sudo add-apt-repository ppa:webupd8team/sublime-text-2
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install sublime-text
|
||||
|
|
|
@ -12,13 +12,13 @@ file from the source, and then you run a separate command to apply it.
|
|||
|
||||
You can save time and typing by running the two commands on one line:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ curl http://drupal.org/files/[patch-name].patch | git apply -v
|
||||
```
|
||||
|
||||
Or, if you don't have curl installed, you can use wget:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ wget -q -O - http://drupal.org/files/[patch-name].patch | git apply -v
|
||||
```
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ for links based on their location on the page -
|
|||
[extracting some Tailwind components](https://tailwindcss.com/docs/extracting-components).
|
||||
|
||||
<div v-pre markdown="1">
|
||||
```vuejs
|
||||
```html
|
||||
<template>
|
||||
...
|
||||
|
||||
|
@ -101,7 +101,7 @@ Within the `style` section, I’m able to use Tailwind’s custom `@apply` direc
|
|||
to inject it’s rules into more traditional CSS, rather than needing to add them
|
||||
onto every link.
|
||||
|
||||
```vuejs
|
||||
```vue-html
|
||||
<style lang="sass">
|
||||
#header a
|
||||
@apply text-white no-underline
|
||||
|
@ -135,7 +135,7 @@ can be done within Vue. As the page could potentially have multiple sidebar
|
|||
blocks, I extracted a `SidebarBlock` component which would act as a wrapper
|
||||
around the block’s contents.
|
||||
|
||||
```vuejs
|
||||
```vue-html
|
||||
// src/components/Sidebar.vue
|
||||
|
||||
<template>
|
||||
|
@ -201,7 +201,7 @@ I added only the page-specific styling classes to the link (as well as the
|
|||
`skip-link` class that the plugin requires) as well as my own focus state to the
|
||||
skip link that I did within the `style` section of `App.vue`.
|
||||
|
||||
```vuejs
|
||||
```vue-html
|
||||
<style lang="sass">
|
||||
@tailwind preflight
|
||||
@tailwind components
|
||||
|
|
|
@ -89,7 +89,7 @@ export default {
|
|||
`src/components/Welcome.vue`:
|
||||
|
||||
<div v-pre markdown="1">
|
||||
```vuejs
|
||||
```vue-html
|
||||
<template>
|
||||
<div>
|
||||
<div class="bg-blue-dark">
|
||||
|
@ -233,7 +233,7 @@ markup which makes the component easier to read and maintain.
|
|||
|
||||
<div v-pre markdown="1">
|
||||
|
||||
```vuejs
|
||||
```vue-html
|
||||
<template>
|
||||
<div>
|
||||
<button
|
||||
|
|
|
@ -138,7 +138,7 @@ A list of all the environment variables can be seen by running
|
|||
`symfony var:export` (add `| tr " " "\n"` if you want to view each one on a new
|
||||
line, and `| sort` if you want to list them alphabetically):
|
||||
|
||||
```dotenv
|
||||
```
|
||||
DATABASE_DATABASE=main
|
||||
DATABASE_DRIVER=mysql
|
||||
DATABASE_HOST=127.0.0.1
|
||||
|
|
|
@ -26,7 +26,7 @@ To use it, download and enable it from Drupal.org as you would for any other
|
|||
module, and then add it as a dependency within your module. The xautoload
|
||||
project page suggests including a minimum version in this format:
|
||||
|
||||
```language-ini
|
||||
```ini
|
||||
dependencies[] = xautoload (>= 7.x-5.0)
|
||||
```
|
||||
|
||||
|
@ -38,7 +38,7 @@ This will ensure that the version of xautoload is 7.x-5.0 or newer.
|
|||
|
||||
Here is an example .info file for a migrate module.
|
||||
|
||||
```language-ini
|
||||
```ini
|
||||
; foo_migrate.info
|
||||
|
||||
name = Foo Migration
|
||||
|
@ -58,7 +58,7 @@ One thing that the xautoload module does to enable for the use of wildcards
|
|||
within this syntax. By using wildcards, the module file can be simplified as
|
||||
follows:
|
||||
|
||||
```language-ini
|
||||
```ini
|
||||
files[] = includes/**/*.inc
|
||||
```
|
||||
|
||||
|
@ -93,7 +93,7 @@ In order to do so, you’ll need to complete the following steps:
|
|||
|
||||
Now your class may look something like this:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php
|
||||
|
||||
namespace Drupal\foo_migrate\Node;
|
||||
|
@ -111,7 +111,7 @@ they are no longer needed and any classes will be loaded automatically.
|
|||
Within `foo_migrate.migrate.inc`, I can now reference any class names using
|
||||
their full namespace:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$node_arguments['ArticleNode'] = array(
|
||||
'class_name' => 'Drupal\foo_migrate\Node\FooArticleNodeMigration',
|
||||
'source_type' => 'story',
|
||||
|
|
|
@ -11,7 +11,7 @@ and Git Flow commands.
|
|||
|
||||
These should be placed within your `~/.bashrc` or `~/.bash_profile` file:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
alias gi="git init"
|
||||
alias gcl="git clone"
|
||||
alias gco="git checkout"
|
||||
|
|
|
@ -52,7 +52,7 @@ to it and push it.
|
|||
|
||||
For example:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
cd web/modules/custom/my_new_module
|
||||
|
||||
# Create a new Git repository.
|
||||
|
|
|
@ -23,7 +23,7 @@ change is **node-blog.tpl.php**
|
|||
|
||||
I scrolled down until I found the piece of code that displayed the terms list:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
<?php if ($terms): ?>
|
||||
<div class="terms terms-inline">
|
||||
<?php print t('Posted in') . $terms; ?>
|
||||
|
@ -37,7 +37,7 @@ outputing the terms.
|
|||
I then added some CSS to re-size the spacing between the items, and then add the
|
||||
commas between them to seperate them:
|
||||
|
||||
```language-css
|
||||
```css
|
||||
.terms ul.links li {
|
||||
margin-right: 1px;
|
||||
padding: 0;
|
||||
|
@ -56,7 +56,7 @@ I created a file named **script.js** in my theme folder with the following code
|
|||
in it. After clearing Drupal's caches, this file is automatically recognised by
|
||||
Drupal 6.
|
||||
|
||||
```language-js
|
||||
```js
|
||||
if (Drupal.jsEnabled) {
|
||||
$(document).ready(function() {
|
||||
$('.terms ul.links li.last').prev().addClass('test');
|
||||
|
@ -68,7 +68,7 @@ This code finds the last item in the list, uses **.prev** to select the one
|
|||
before it, and then uses **.addClass** to assign it the HTML class of "test". We
|
||||
can then use this class to target it with specific CSS.
|
||||
|
||||
```language-css
|
||||
```css
|
||||
.terms ul.links li.test:after {
|
||||
content: " and";
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ generates.
|
|||
We also need to add `tailwindcss` and `postcss` so that we can use them within
|
||||
the tests.
|
||||
|
||||
```plain
|
||||
```
|
||||
yarn add -D jest jest-matcher-css postcss tailwindcss@next
|
||||
```
|
||||
|
||||
|
@ -242,7 +242,7 @@ time new commits are pushed.
|
|||
This is done by adding a `.travis-ci.yml` file to the repository, like this one
|
||||
which is based on the [JavaScript and Node.js example][travis-nodejs-example]:
|
||||
|
||||
```yml
|
||||
```yaml
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
|
|
|
@ -23,7 +23,7 @@ To do this, I needed to expose the module to the Features API.
|
|||
|
||||
All that’s needed is to add this line to the `mymodule.info` file:
|
||||
|
||||
```language-ini
|
||||
```ini
|
||||
features[features_api][] = api:2
|
||||
```
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ feature name and the component names.
|
|||
|
||||
For example:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush features-export -y myfeature field_base:field_foo field_instance:user-field_foo
|
||||
```
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ I had a quick look for a _Update my fork_ button or something, but couldn't see
|
|||
one to I added the main repository as an additional remote called `upstream` and
|
||||
fetched the changes.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ git remote add upstream https://github.com/sculpin/sculpin.io.git
|
||||
|
||||
$ git fetch upstream
|
||||
|
@ -60,7 +60,7 @@ Now my local site knows about the upstream repo, and I could rebase the changes
|
|||
(`git pull upstream master` should have worked too) and push them back to
|
||||
origin.
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ git rebase upstream/master
|
||||
First, rewinding head to replay your work on top of it...
|
||||
...
|
||||
|
|
|
@ -29,7 +29,7 @@ The first thing to do was to run the existing tests and check that they still
|
|||
passed. I do this on the command line by typing
|
||||
`php scripts/run-tests.sh --class OverrideNodeOptionsTestCase`.
|
||||
|
||||
```language-markup
|
||||
```
|
||||
Drupal test run
|
||||
---------------
|
||||
|
||||
|
@ -52,7 +52,7 @@ what could be re-used.
|
|||
|
||||
This is one of the original tests:
|
||||
|
||||
```language-php
|
||||
```php
|
||||
/**
|
||||
* Test the 'Authoring information' fieldset.
|
||||
*/
|
||||
|
@ -94,7 +94,7 @@ called `$generalUser` and run the first part of the tests in a loop.
|
|||
|
||||
With the tests passing, I was able to start refactoring.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
// Create a new user with content type specific permissions.
|
||||
$specificUser = $this->drupalCreateUser(array(
|
||||
'create page content',
|
||||
|
@ -123,7 +123,7 @@ After that change, I ran the tests again to check that everything still worked.
|
|||
|
||||
The next step is to start testing the new permissions.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
...
|
||||
|
||||
$generalUser = $this->drupalCreateUser(array());
|
||||
|
@ -139,7 +139,7 @@ I added a new `$generalUser` to test the general permissions and added to the
|
|||
loop, but in order to see the tests failing intially I assigned it no
|
||||
permissions. When running the tests again, 6 tests have failed.
|
||||
|
||||
```language-markup
|
||||
```
|
||||
Test summary
|
||||
------------
|
||||
|
||||
|
@ -163,7 +163,7 @@ that the
|
|||
|
||||
This was fixed by adding the extra code into `override_node_options.module`.
|
||||
|
||||
```language-diff
|
||||
```diff
|
||||
- $form['comment_settings']['#access'] |= user_access('override ' . $node->type . ' comment setting option');
|
||||
+ $form['comment_settings']['#access'] |= user_access('override ' . $node->type . ' comment setting option') || user_access('override all comment setting option');
|
||||
```
|
||||
|
@ -177,7 +177,7 @@ Note: You can get more verbose output from `run-tests.sh` by adding the
|
|||
|
||||
> Node vid was updated to '3', expected 2.
|
||||
|
||||
```language-diff
|
||||
```diff
|
||||
- $fields = array(
|
||||
- 'revision' => TRUE,
|
||||
- );
|
||||
|
@ -223,7 +223,7 @@ version of the node was loaded during each loop.
|
|||
With the refactoring complete, the number of passing tests increased from 142
|
||||
to 213.
|
||||
|
||||
```language-markup
|
||||
```
|
||||
Override node options 213 passes, 0 fails, 0 exceptions, and 60 debug messages
|
||||
|
||||
Test run duration: 25 sec
|
||||
|
|
|
@ -17,7 +17,7 @@ I'd generated a list of node ID values, and needed to add structure the SQL
|
|||
update statment formatted in a certain way. However, I changed my inital query
|
||||
slightly to out put the same nid value twice.
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
SELECT nid, nid FROM node WHERE TYPE = 'blog' ORDER BY nid ASC;
|
||||
```
|
||||
|
||||
|
@ -26,7 +26,7 @@ into Coda:
|
|||
|
||||
As before, I needed my SQL update statement to be in the following format:
|
||||
|
||||
```language-sql
|
||||
```sql
|
||||
INSERT INTO term_node VALUE (nid, vid, tid), (nid2, vid2, tid);
|
||||
```
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ The first thing to do is download the PHPSass library from
|
|||
a requirement of the Sassy module and we can't enable it without the library.
|
||||
So, in a Terminal window:
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ mkdir -p sites/all/libraries;
|
||||
$ cd sites/all/libraries;
|
||||
$ wget https://github.com/richthegeek/phpsass/archive/master.tar.gz;
|
||||
|
@ -44,7 +44,7 @@ $ mv phpsass-master/ phpsass
|
|||
|
||||
Or, if you're using Drush Make files:
|
||||
|
||||
```language-ini
|
||||
```ini
|
||||
libraries[phpsass][download][type] = "get"
|
||||
libraries[phpsass][download][url] = "https://github.com/richthegeek/phpsass/archive/master.tar.gz"
|
||||
```
|
||||
|
@ -55,7 +55,7 @@ The PHPSass library should now be located at `sites/all/libraries/phpsass`.
|
|||
|
||||
This is easy if you use [Drush](http://drupal.org/project/drush):
|
||||
|
||||
```language-bash
|
||||
```bash
|
||||
$ drush dl libraries prepro sassy
|
||||
$ drush en -y libraries prepro sassy sassy_compass
|
||||
```
|
||||
|
|
|
@ -27,7 +27,7 @@ console.log(Encore.getWebpackConfig().module.rules)
|
|||
|
||||
There I can see the the test for PostCSS supports the `.css` and `.postcss` file extensions, but not `.pcss`.
|
||||
|
||||
```plain
|
||||
```
|
||||
test: /\.(css|postcss)$/,
|
||||
```
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ better to configure this within your settings.php or settings.local.php file. We
|
|||
do this using the `$conf` array which removes the need to configure the module
|
||||
through the UI and store the values in the database.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
// File proxy to the live site.
|
||||
$conf['stage_file_proxy_origin'] = 'http://www.example.com';
|
||||
|
||||
|
@ -32,6 +32,6 @@ If the origin site is not publicly accessible yet, maybe it's a pre-live or
|
|||
staging site, and protected with a basic access authentication, you can include
|
||||
the username and password within the origin URL.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
$conf['stage_file_proxy_origin'] = 'http://user:password@prelive.example.com';
|
||||
```
|
||||
|
|
|
@ -40,7 +40,7 @@ your custom theme's directory (e.g. `sites/all/themes/custom/mytheme` for Drupal
|
|||
Create a `postcss.config.js` file and add `tailwindcss` as a plugin, passing the
|
||||
path to the config file:
|
||||
|
||||
```language-js
|
||||
```js
|
||||
module.exports = {
|
||||
plugins: [
|
||||
require('tailwindcss')('./tailwind.js'),
|
||||
|
@ -54,7 +54,7 @@ There are some configuration settings within `tailwind.js` that you’ll need to
|
|||
change to make things work nicely with Drupal. These are within the `options`
|
||||
section:
|
||||
|
||||
```language-js
|
||||
```js
|
||||
options: {
|
||||
prefix: 'tw-',
|
||||
important: true,
|
||||
|
@ -85,7 +85,7 @@ rules.
|
|||
For example: if I had this core markup then the left margin added by `tw-ml-4`
|
||||
would be overridden by core’s `.item-list ul` styling.
|
||||
|
||||
```language-html
|
||||
```html
|
||||
<div class="item-list">
|
||||
<ul class="tw-ml-4">
|
||||
...
|
||||
|
|
|
@ -9,7 +9,7 @@ tags:
|
|||
- theming
|
||||
---
|
||||
|
||||
```language-ini
|
||||
```ini
|
||||
name = My Theme
|
||||
description = A description of my theme
|
||||
core = 7.x
|
||||
|
|
|
@ -43,7 +43,7 @@ For the module, we are going to satisfy this example acceptance criteria:
|
|||
Let’s start by writing the minimal code needed in order for the new module to be
|
||||
enabled. In Drupal 8, this is the `.info.yml` file.
|
||||
|
||||
```language-yaml
|
||||
```yaml
|
||||
# tdd_dublin.info.yml
|
||||
|
||||
name: 'TDD Dublin'
|
||||
|
@ -58,7 +58,7 @@ is a functional test, it extends the `BrowserTestBase` class, and we need to
|
|||
ensure that the tdd_dublin module is enabled by adding it to the `$modules`
|
||||
array.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
// tests/src/Functional/PageListTest.php
|
||||
|
||||
namespace Drupal\Tests\tdd_dublin\Functional;
|
||||
|
@ -85,7 +85,7 @@ be 200, otherwise it will be 404.
|
|||
I usually like to write comments first within the test method, just to outline
|
||||
the steps that I'm going to take and then replace it with code.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
public function testListingPageExists() {
|
||||
// Go to /pages and check that it is accessible by checking the status
|
||||
// code.
|
||||
|
@ -95,7 +95,7 @@ public function testListingPageExists() {
|
|||
We can use the `drupalGet()` method to browse to the required path, i.e.
|
||||
`/pages`, and then write an assertion for the response code value.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
public function testListingPageExists() {
|
||||
$this->drupalGet('pages');
|
||||
|
||||
|
@ -111,7 +111,7 @@ autoloaded so can be found, though the path to the `vendor` directory may be
|
|||
different depending on your project structure. You can also specify a path
|
||||
within which to run the tests - e.g. within the module’s `test` directory.
|
||||
|
||||
```language-plain
|
||||
```
|
||||
$ vendor/bin/phpunit -c core modules/custom/tdd_dublin/tests
|
||||
```
|
||||
|
||||
|
@ -119,7 +119,7 @@ $ vendor/bin/phpunit -c core modules/custom/tdd_dublin/tests
|
|||
Note: I’m using Docksal, and I’ve noticed that I need to run the tests from within the CLI container. You can do this by running the `fin bash` command.
|
||||
</div>
|
||||
|
||||
```language-plain
|
||||
```
|
||||
1) Drupal\Tests\tdd_dublin\Functional\PageListTest::testListingPageExists
|
||||
Behat\Mink\Exception\ExpectationException: Current response status code is 404, but 200 expected.
|
||||
|
||||
|
@ -158,7 +158,7 @@ of the file needs to be removed so the configuration can be installed.
|
|||
|
||||
Here is the exported view configuration:
|
||||
|
||||
```language-yaml
|
||||
```yaml
|
||||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
|
@ -350,7 +350,7 @@ display:
|
|||
When the test is run again, we see a different error that leads us to the next
|
||||
step.
|
||||
|
||||
```language-plain
|
||||
```
|
||||
1) Drupal\Tests\tdd_dublin\Functional\PageListTest::testListingPageExists
|
||||
Drupal\Core\Config\UnmetDependenciesException: Configuration objects provided by <em class="placeholder">tdd_dublin</em> have unmet dependencies: <em class="placeholder">node.type.page (node), views.view.pages (node, views)</em>
|
||||
|
||||
|
@ -363,7 +363,7 @@ In this case, the view that we’ve added depends on the node and views modules,
|
|||
but these aren’t enabled. To fix this, we can add the extra modules as
|
||||
dependencies of tdd_dublin so they will be enabled too.
|
||||
|
||||
```language-yaml
|
||||
```yaml
|
||||
# tdd_dublin.info.yml
|
||||
|
||||
dependencies:
|
||||
|
@ -371,7 +371,7 @@ dependencies:
|
|||
- drupal:views
|
||||
```
|
||||
|
||||
```language-plain
|
||||
```
|
||||
1) Drupal\Tests\tdd_dublin\Functional\PageListTest::testListingPageExists
|
||||
Drupal\Core\Config\UnmetDependenciesException: Configuration objects provided by <em class="placeholder">tdd_dublin</em> have unmet dependencies: <em class="placeholder">views.view.pages (node.type.page)</em>
|
||||
|
||||
|
@ -386,7 +386,7 @@ configuration and copying it into the `config/install` directory.
|
|||
|
||||
With this in place, the test should now pass - and it does.
|
||||
|
||||
```language-plain
|
||||
```
|
||||
Time: 26.04 seconds, Memory: 6.00MB
|
||||
|
||||
OK (1 test, 1 assertion)
|
||||
|
@ -407,7 +407,7 @@ The objectives of this test are:
|
|||
- To ensure that only page nodes are returned.
|
||||
- To ensure that only published nodes are returned.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
public function testOnlyPublishedPagesAreShown() {
|
||||
// Given that a have a mixture of published and unpublished pages, as well
|
||||
// as other types of content.
|
||||
|
@ -422,7 +422,7 @@ In order to test the different scenarios, I will create an additional "article"
|
|||
content type, create a node of this type as well as one published and one
|
||||
unpublished page. From this combination, I only expect one node to be visible.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
public function testOnlyPublishedPagesAreShown() {
|
||||
$this->drupalCreateContentType(['type' => 'article']);
|
||||
|
||||
|
@ -447,7 +447,7 @@ result of the view. This returns an array of `Drupal\views\ResultRow` objects,
|
|||
which contain the nodes. I can use `array_column` to extract the node IDs from
|
||||
the view result into an array.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
public function testOnlyPublishedPagesAreShown() {
|
||||
$this->drupalCreateContentType(['type' => 'article']);
|
||||
|
||||
|
@ -466,7 +466,7 @@ From the generated nodes, I can use `assertEquals()` to compare the returned
|
|||
node IDs from the view against an array of expected node IDs - in this case, I
|
||||
expect only node 1 to be returned.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
public function testOnlyPublishedPagesAreShown() {
|
||||
$this->drupalCreateContentType(['type' => 'article']);
|
||||
|
||||
|
@ -488,7 +488,7 @@ default "Content: Published" filter is already excluding one of the page nodes.
|
|||
We can see from the output from the test that node 1 (a page) and node 2 (the
|
||||
article) are both being returned.
|
||||
|
||||
```language-plain
|
||||
```
|
||||
1) Drupal\Tests\tdd_dublin\Functional\PageListTest::testOnlyPublishedPagesAreShown
|
||||
Failed asserting that two arrays are equal.
|
||||
--- Expected
|
||||
|
@ -514,7 +514,7 @@ based on the node type - i.e. only return page nodes.
|
|||
Once the view is updated and the configuration is updated within the module, the
|
||||
test should then pass - and it does.
|
||||
|
||||
```language-plain
|
||||
```
|
||||
Time: 24.76 seconds, Memory: 6.00MB
|
||||
|
||||
OK (1 test, 3 assertions)
|
||||
|
@ -528,7 +528,7 @@ As we know that the correct content is being returned, we can now focus on
|
|||
displaying it in the correct order. We’ll start again by adding a new test
|
||||
method and filling out the comments.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
public function testResultsAreOrderedAlphabetically() {
|
||||
// Given I have multiple nodes with different titles.
|
||||
|
||||
|
@ -543,7 +543,7 @@ title for each. These are intentionally in the incorrect order alphabetically so
|
|||
that we can see the test fail initially and then see it pass after making a
|
||||
change so we know that the change worked.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
public function testResultsAreOrderedAlphabetically() {
|
||||
$this->drupalCreateNode(['title' => 'Page A']);
|
||||
$this->drupalCreateNode(['title' => 'Page D']);
|
||||
|
@ -561,7 +561,7 @@ We can use the same method as the previous test to get the returned IDs, using
|
|||
node IDs match the expected node IDs in the specified order. Based on the
|
||||
defined titles, the order should be 1, 4, 3, 2.
|
||||
|
||||
```language-php
|
||||
```php
|
||||
public function testResultsAreOrderedAlphabetically() {
|
||||
$this->drupalCreateNode(['title' => 'Page A']);
|
||||
$this->drupalCreateNode(['title' => 'Page D']);
|
||||
|
@ -586,7 +586,7 @@ This would be particularly more complicated to test if I was using `drupalGet()`
|
|||
and having to parse the HTML, compared to getting the results as an array from
|
||||
the view programmatically.
|
||||
|
||||
```language-plain
|
||||
```
|
||||
1) Drupal\Tests\tdd_dublin\Functional\PageListTest::testResultsAreOrderedAlphabetically
|
||||
Failed asserting that two arrays are equal.
|
||||
--- Expected
|
||||
|
@ -617,7 +617,7 @@ based on "Content: Title".
|
|||
Again, once the view has been updated and exported, the test should pass - and
|
||||
it does.
|
||||
|
||||
```language-plain
|
||||
```
|
||||
Time: 27.55 seconds, Memory: 6.00MB
|
||||
|
||||
OK (1 test, 2 assertions)
|
||||
|
@ -629,7 +629,7 @@ Now we know that all the tests pass individually, all of the module tests should
|
|||
now be run to ensure that they all still pass and that there have been no
|
||||
regressions due to any of the changes.
|
||||
|
||||
```language-plain
|
||||
```
|
||||
docker@cli:/var/www$ vendor/bin/phpunit -c core modules/custom/tdd_dublin/tests
|
||||
|
||||
Testing modules/custom/tdd_dublin/tests
|
||||
|
|
|
@ -36,7 +36,7 @@ Once installed, run `:DBUIAddconnection` to add a database connection.
|
|||
|
||||
Here is an example connection string:
|
||||
|
||||
```plain
|
||||
```
|
||||
mysql://drupal:drupal@localhost:3307/drupal?protocol=tcp
|
||||
```
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ Instead of doing this manually, I can achieve the same thing though using a tool
|
|||
|
||||
Here's an example where I'm automatically re-running my PHPUnit tests using a `just test` recipe each time a file within my custom modules directory changes:
|
||||
|
||||
```plain
|
||||
```
|
||||
nodemon \
|
||||
--watch web/modules/custom \
|
||||
--ext '*' \
|
||||
|
|
Loading…
Reference in a new issue