public static function alterNodeParameters(BeforeNodeCreateScope $scope)
    {
        $node = $scope->getEntity();

        // Get the Drupal API version if available. This is not available when
        // using e.g. the BlackBoxDriver or DrushDriver.
        $api_version = null;
        $driver = $scope->getContext()->getDrupal()->getDriver();
        if ($driver instanceof \Drupal\Driver\DrupalDriver) {
            $api_version = $scope->getContext()->getDrupal()->getDriver()->version;
        }

        // On Drupal 8 the timestamps should be in UNIX time.
        switch ($api_version) {
            case 8:
                foreach (array('changed', 'created', 'revision_timestamp') as $field) {
                    if (!empty($node->$field) && !is_numeric($node->$field)) {
                        $node->$field = strtotime($node->$field);
                    }
                }
                break;
        }
    }
public static function alterNodeParameters(BeforeNodeCreateScope $scope)
    {
        $node = $scope->getEntity();

        // Get the Drupal API version if available. This is not available when
        // using e.g. the BlackBoxDriver or DrushDriver.
        $api_version = null;
        $driver = $scope->getContext()->getDrupal()->getDriver();
        if ($driver instanceof \Drupal\Driver\DrupalDriver) {
            $api_version = $scope->getContext()->getDrupal()->getDriver()->version;
        }

        // On Drupal 8 the timestamps should be in UNIX time.
        switch ($api_version) {
            case 8:
                foreach (array('changed', 'created', 'revision_timestamp') as $field) {
                    if (!empty($node->$field) && !is_numeric($node->$field)) {
                        $node->$field = strtotime($node->$field);
                    }
                }
                break;
        }
    }
public static function alterNodeParameters ( BeforeNodeCreateScope $ scope ) { $ node = $ scope -> getEntity ( ) ; // Get the Drupal API version if available. This is not available when // using e.g. the BlackBoxDriver or DrushDriver. $ api_version = null ; $ driver = $ scope -> getContext ( ) -> getDrupal ( ) -> getDriver ( ) ; if ( $ driver instanceof \ Drupal \ Driver \ DrupalDriver ) { $ api_version = $ scope -> getContext ( ) -> getDrupal ( ) -> getDriver ( ) -> version ; } // On Drupal 8 the timestamps should be in UNIX time. switch ( $ api_version ) { case 8 : foreach ( array ( 'changed' , 'created' , 'revision_timestamp' ) as $ field ) { if ( ! empty ( $ node -> $ field ) && ! is_numeric ( $ node -> $ field ) ) { $ node -> $ field = strtotime ( $ node -> $ field ) ; } } break ; } }
Massage node values to match the expectations on different Drupal versions.

@beforeNodeCreate
Massage node values to match the expectations on different Drupal versions .