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
// hooks/useScript.js | |
import { useEffect } from 'react'; | |
const useScript = url => { | |
useEffect(() => { | |
const script = document.createElement('script'); | |
script.src = url; | |
script.async = true; |
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
const atv = { | |
make: 'Honda', | |
model: 'Rincon 650', | |
year: 2018, | |
mud: () => { | |
console.log('Mudding'); | |
} | |
}; | |
const secondATV = Object.create(atv); |
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
class Car { | |
constructor(make, model, year, isForSale = true, isInStock = false) { | |
this.make = make; | |
this.model = model; | |
this.year = year; | |
this.isForSale = isForSale; | |
this.isInStock = isInStock; | |
} | |
toString() { |
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
import Motorvehicle from './Motorvehicle'; | |
import Aircraft from './Aircraf'; | |
import Railvehicle from './Railvehicle'; | |
const VehicleFactory = (type, make, model, year) => { | |
if (type === car) { | |
return new Motorvehicle('car', make, model, year); | |
} else if (type === airplane) { | |
return new Aircraft('airplane', make, model, year); | |
} else if (type === helicopter) { |
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
// The 4 Creational Design Patterns In Node.js | |
// https://daily.dev/blog/the-4-creational-design-patterns-in-node-js-you-should-know | |
// The Singletone Pattern | |
class DatabaseConnection { | |
constructor() { | |
this.databaseConnection = 'dummytext'; | |
} |
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 Drupal\MY_MODULE\Plugin\views\style; | |
use Drupal\rest\Plugin\views\style\Serializer; | |
/** | |
* The style plugin for serialized output formats. | |
* | |
* @ingroup views_style_plugins | |
* |
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 | |
// Source https://www.flocondetoile.fr/blog/provide-custom-mode-form-entities-drupal-8 | |
/** | |
* Implements hook_entity_type_build(). | |
*/ | |
function my_module_entity_type_build(array &$entity_types) { | |
$entity_types['user']->setFormClass('profil', 'Drupal\user\ProfileForm'); | |
} |
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 | |
// Source https://www.droptica.com/blog/custom-entity-forms-example-user-editing-and-registration/ | |
/** | |
* Implements hook_entity_type_build(). | |
*/ | |
function my_module_entity_type_build(array &$entity_types) { | |
$form_modes = ['custom_form_mode_1', 'custom_form_mode_2']; |
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 Drupal\axl_ks_topics\Plugin\EntityReferenceSelection; | |
use Drupal\Component\Utility\Html; | |
use Drupal\Core\Database\Connection; | |
use Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase; | |
use Drupal\Core\Entity\EntityTypeManagerInterface; | |
use Drupal\Core\Entity\Query\QueryInterface; | |
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; |
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 Drupal\sandbox\Form; | |
use Drupal\Core\Form\FormBase; | |
use Drupal\Core\Form\FormInterface; | |
use Drupal\Core\Form\FormState; | |
use Drupal\Core\Form\FormStateInterface; | |
use Drupal\node\Entity\Node; | |
use Drupal\user\Entity\User; |