This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Backup | |
# Added current date and time to generated file name. | |
docker exec preprod_safefood_vitrine_mariadb /usr/bin/mysqldump -u safefood_vitrine --password=safefood_vitrine123 drupal > $(date +"%Y_%m_%d_%I_%M_%p").sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 rwx | |
6 rw- | |
5 r-x | |
4 r-- | |
3 -wx | |
2 -w- | |
1 --x | |
0 --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Contains \Drupal\example_module\Controller\ExampleModuleController. | |
*/ | |
// THIS FILE BELONGS AT /example_module/src/Controller/ExampleModuleController.php | |
namespace Drupal\example_module\Controller; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace CoreBundle\Service; | |
use CoreBundle\Entity\User; | |
use Psr\Cache\CacheItemPoolInterface; | |
use Symfony\Component\Cache\Adapter\AbstractAdapter; | |
use Symfony\Component\Cache\Adapter\AdapterInterface; | |
class UserTokenService |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$credentials = base64_encode("admin:SuperSecret123"); | |
$apiResponse = $this->client->get("{$this->container->getParameter('api')}jwt/token", | |
[ | |
'verify' => false, | |
'headers' => [ | |
'Authorization' => 'Basic ' . $credentials, | |
], | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl --insecure -X POST -H "Content-Type: application/json" https://front.site-dev.fr:8002/api/login_check -d '{"username":"johndoe","password":"test"}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Logs a notice | |
\Drupal::logger('my_module')->notice($message); | |
// Logs an error | |
\Drupal::logger('my_module')->error($message); | |
// Logs an info | |
\Drupal::logger('my_module')->info($message); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM key_value WHERE collection="system.schema"; | |
UPDATE key_value SET value='s:4:"8003";' WHERE collection="system.schema" AND name="mymodule"; | |
How to "revert" a custom module's update 'N value' | |
D7 only: If you need to execute an update hook another time when testing it locally you can "revert" a custom module's update 'N value' with: | |
UPDATE system SET schema_version = [last_successful_update_ID] WHERE name = '[name_of_module]'; | |
Replace the square brackets plus its content. See https://drupal.stackexchange.com/a/69841/19480. | |
Examples: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
attributes.addClass() | |
Adds classes or merges them on to array of existing CSS classes. | |
Single class: | |
<div{{ attributes.addClass('my-class') }}></div> | |
Multiple classes: | |
{% | |
set classes = [ | |
'red', | |
'green', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<img src="img_snow_wide.jpg" alt="Snow" style="width:100%;"> | |
<div class="bottom-left">Bottom Left</div> | |
<div class="top-left">Top Left</div> | |
<div class="top-right">Top Right</div> | |
<div class="bottom-right">Bottom Right</div> | |
<div class="centered">Centered</div> | |
</div> | |
/* Bottom left text */ |