Сохранить внутреннюю ссылку в поле типа ссылка

Главные вкладки

Аватар пользователя Riaron Riaron 17 сентября 2019 в 23:16

Как сохранить внутреннюю ссылку в поле типа ссылка

<?php
                    $nod
->field_zlinkUrl::fromInternalUri('dforders?title='.$tit);// строка 231

?>

на данном коде выдает ошибку: Error: Call to protected method Drupal\Core\Url::fromInternalUri() from context '' в shop_atorders() (строка 231

Комментарии

Аватар пользователя Riaron Riaron 18 сентября 2019 в 23:37

теперь ругается на другое (причем и до этого и сейчас orders сохраняется но без ссылки и юзера)
Recoverable fatal error: Object of class Drupal\Core\Url could not be converted to string в drupal_schema_get_field_value() (строка 229

<?php
  $user 
User::load(\Drupal::currentUser()->id());

   

$a = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties([
        
'type' => 'basket',
        
'field_polzovatel' => $user->getUsername(),
    ]);
     
$node reset($a);
  
$tit=generateCode(10);
    
$nod Node::create([
                    
// The node entity bundle.
                    
'type' => 'zakazy',
                    ]);
                    
                    
$nod->set('title',$tit);
                    
$nod->set('uid',1);
                    
$nod->status=1;
                    
$nod->field_zitogo$node->field_itogo;
                    
$nod->field_zpolzovatel$node->field_polzovatel;//строка 229
                    
$nod->field_zartikuly$node->field_artikuly;
                    
$nod->field_zlinkUrl::fromUserInput('/internal:/dforders?title='.$tit);;
                    
$nod->enforceIsNew;
                    
$nod->save();
?>
Аватар пользователя Riaron Riaron 19 сентября 2019 в 20:24

все наладил но с сохранением ссылки сложно Recoverable fatal error: Object of class Drupal\Core\Url could not be converted to string

<?php
Url
::fromUserInput('/internal:/dforders?title='.$tit)
?>