Views: 3071
Last Modified: 29.03.2022
  • isFilled

    The method isFilled is used to verify, if object contains a current actual value from the database:

    use \Bitrix\Main\Test\Typography\Book;
    
    // Values from fetch* and wakeUp methods are deemed as actual 
    // the example demonstrates how only primary key is passed when initializing an object
    $book = Book::wakeUp(1);
    
    var_dump($book->isTitleFilled());
    // false
    
    $book->fillTitle();
    
    var_dump($book->isTitleFilled());
    // true
  • isChanged

    The method isChanged responds to question if a new value was set during the session:

    use \Bitrix\Main\Test\Typography\Book;
    
    // object may have source value, but may not 
    // this doesn't affect the further behaviour
    $book = Book::wakeUp(['ID' => 1, 'TITLE' => 'Title 1']);
    
    var_dump($book->isTitleChanged());
    // false
    
    $book->setTitle('New title 1');
    
    var_dump($book->isTitleChanged());
    // true

    Such behaviour is applicable for new objects as well, until their values are stored in the database.

  • has

    The method has checks, if an object has a field value - an actual value from the database or value, specified during the session. In fact, its an abbreviation from isFilled() || isChanged():

    use \Bitrix\Main\Test\Typography\Book;
    
    $book = Book::wakeUp(['ID' => 1, 'TITLE' => 'Title 1']);
    $book->setIsArchived(true);
    
    var_dump($book->hasTitle());
    // true
    
    var_dump($book->hasIsArchived());
    // true
    
    var_dump($book->hasIsbn());
    // false




Courses developed by Bitrix24